MCPcopy Create free account
hub / github.com/pion/ice / TestRandomGeneratorCollision

Function TestRandomGeneratorCollision

rand_test.go:13–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestRandomGeneratorCollision(t *testing.T) {
14 candidateIDGen := newCandidateIDGenerator()
15
16 testCases := map[string]struct {
17 gen func(t *testing.T) string
18 }{
19 "CandidateID": {
20 gen: func(*testing.T) string {
21 return candidateIDGen.Generate()
22 },
23 },
24 "PWD": {
25 gen: func(t *testing.T) string {
26 t.Helper()
27
28 s, err := generatePwd()
29 require.NoError(t, err)
30
31 return s
32 },
33 },
34 "Ufrag": {
35 gen: func(t *testing.T) string {
36 t.Helper()
37
38 s, err := generateUFrag()
39 require.NoError(t, err)
40
41 return s
42 },
43 },
44 }
45
46 const num = 100
47 const iteration = 100
48
49 for name, testCase := range testCases {
50 t.Run(name, func(t *testing.T) {
51 for range iteration {
52 var wg sync.WaitGroup
53 var mu sync.Mutex
54
55 rands := make([]string, 0, num)
56
57 for range num {
58 wg.Add(1)
59 go func() {
60 r := testCase.gen(t)
61 mu.Lock()
62 rands = append(rands, r)
63 mu.Unlock()
64 wg.Done()
65 }()
66 }
67 wg.Wait()
68
69 require.Len(t, rands, num)
70 for i := range num {

Callers

nothing calls this directly

Calls 6

newCandidateIDGeneratorFunction · 0.85
generatePwdFunction · 0.85
generateUFragFunction · 0.85
GenerateMethod · 0.80
RunMethod · 0.80
DoneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…