TestRandomStringConcurrent guards the pooled scratch buffers in randomString: concurrent callers must not share/alias a buffer and corrupt each other's output. Run with -race.
(t *testing.T)
| 12 | // TestRandomStringConcurrent guards the pooled scratch buffers in randomString: concurrent callers |
| 13 | // must not share/alias a buffer and corrupt each other's output. Run with -race. |
| 14 | func TestRandomStringConcurrent(t *testing.T) { |
| 15 | const goroutines, iterations = 100, 300 |
| 16 | var wg sync.WaitGroup |
| 17 | wg.Add(goroutines) |
| 18 | for g := 0; g < goroutines; g++ { |
| 19 | go func() { |
| 20 | defer wg.Done() |
| 21 | for i := 0; i < iterations; i++ { |
| 22 | s := randomString(32) |
| 23 | if len(s) != 32 { |
| 24 | t.Errorf("expected length 32, got %d (%q)", len(s), s) |
| 25 | return |
| 26 | } |
| 27 | for _, r := range s { |
| 28 | if !strings.ContainsRune(randomStringCharset, r) { |
| 29 | t.Errorf("char %q not in charset (%q)", r, s) |
| 30 | return |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | }() |
| 35 | } |
| 36 | wg.Wait() |
| 37 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…