github.com/egonelbre/exp@v0.0.0-20240430123955-ed1d3aa93911/bit/zigzag_test.go (about) 1 package bit 2 3 import ( 4 "math/rand" 5 "testing" 6 ) 7 8 func TestZigRandom(t *testing.T) { 9 for i := 0; i < 15315; i += 1 { 10 x := rand.Int63() 11 if rand.Intn(2) == 1 { 12 x = -x 13 } 14 rx := ZEncode(x) 15 rrx := ZDecode(rx) 16 if rrx != x { 17 t.Fatalf("failed %v: %v / %v", x, rx, rrx) 18 } 19 } 20 }