MCPcopy
hub / github.com/tdewolff/minify / TestNumberRandom

Function TestNumberRandom

common_test.go:333–350  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

331}
332
333func TestNumberRandom(t *testing.T) {
334 N := int(1e4)
335 if testing.Short() {
336 N = 0
337 }
338 for i := 0; i < N; i++ {
339 b := RandNumBytes(true)
340 f, _ := strconv.ParseFloat(string(b), 64)
341
342 b2 := make([]byte, len(b))
343 copy(b2, b)
344 b2 = Number(b2, -1)
345 f2, _ := strconv.ParseFloat(string(b2), 64)
346 if math.Abs(f-f2) > 1e-6 {
347 fmt.Println("Bad:", f, "!=", f2, "in", string(b), "to", string(b2))
348 }
349 }
350}
351
352////////////////
353

Callers

nothing calls this directly

Calls 5

RandNumBytesFunction · 0.85
lenFunction · 0.85
NumberFunction · 0.85
stringFunction · 0.50
copyFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…