MCPcopy Create free account
hub / github.com/stretchr/testify / TestDiffRace

Function TestDiffRace

assert/assertions_test.go:2615–2646  ·  view source on GitHub ↗

Ensure there are no data races

(t *testing.T)

Source from the content-addressed store, hash-verified

2613
2614// Ensure there are no data races
2615func TestDiffRace(t *testing.T) {
2616 t.Parallel()
2617
2618 expected := map[string]string{
2619 "a": "A",
2620 "b": "B",
2621 "c": "C",
2622 }
2623
2624 actual := map[string]string{
2625 "d": "D",
2626 "e": "E",
2627 "f": "F",
2628 }
2629
2630 // run diffs in parallel simulating tests with t.Parallel()
2631 numRoutines := 10
2632 rChans := make([]chan string, numRoutines)
2633 for idx := range rChans {
2634 rChans[idx] = make(chan string)
2635 go func(ch chan string) {
2636 defer close(ch)
2637 ch <- diff(expected, actual)
2638 }(rChans[idx])
2639 }
2640
2641 for _, ch := range rChans {
2642 for msg := range ch {
2643 NotZero(t, msg) // dummy assert
2644 }
2645 }
2646}
2647
2648type mockTestingT struct {
2649 errorFmt string

Callers

nothing calls this directly

Calls 2

diffFunction · 0.70
NotZeroFunction · 0.70

Tested by

no test coverage detected