MCPcopy Create free account
hub / github.com/egonelbre/exp / TestShuffleRandom

Function TestShuffleRandom

permutation/code_test.go:67–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

65}
66
67func TestShuffleRandom(t *testing.T) {
68 for i := 0; i < 100; i++ {
69 var perm [base]byte
70 for k, v := range rand.Perm(base) {
71 perm[k] = byte(v)
72 }
73
74 encoded := CodeShuffle(perm)
75 unroll := CodeShuffleUnroll(perm)
76 if encoded > maxAllowed {
77 t.Fatalf("%v: encoded value too large %v >= %v", perm, encoded, maxAllowed)
78 }
79 if encoded != unroll {
80 t.Fatalf("%v: encoded %v, unroll %v", perm, encoded, unroll)
81 }
82
83 decoded := DecodeShuffle(encoded)
84 if !bytes.Equal(perm[:], decoded[:]) {
85 t.Fatalf("%v: got %v, decoded %v", perm, encoded, decoded)
86 }
87 }
88}
89
90func BenchmarkCopy(b *testing.B) {
91 for i := 0; i < b.N; i++ {

Callers

nothing calls this directly

Calls 3

CodeShuffleFunction · 0.85
CodeShuffleUnrollFunction · 0.85
DecodeShuffleFunction · 0.85

Tested by

no test coverage detected