github.com/zhangyunhao116/fastrand@v0.4.0/fastrand_test.go (about) 1 package fastrand 2 3 import ( 4 "testing" 5 ) 6 7 func TestAll(t *testing.T) { 8 _ = Uint32() 9 10 p := make([]byte, 1000) 11 n, err := Read(p) 12 if n != len(p) || err != nil || (p[0] == 0 && p[1] == 0 && p[2] == 0) { 13 t.Fatal() 14 } 15 16 a := Perm(100) 17 for i := range a { 18 var find bool 19 for _, v := range a { 20 if v == i { 21 find = true 22 } 23 } 24 if !find { 25 t.Fatal() 26 } 27 } 28 29 Shuffle(len(a), func(i, j int) { 30 a[i], a[j] = a[j], a[i] 31 }) 32 for i := range a { 33 var find bool 34 for _, v := range a { 35 if v == i { 36 find = true 37 } 38 } 39 if !find { 40 t.Fatal() 41 } 42 } 43 }