(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestExamples(t *testing.T) { |
| 9 | tests := []struct { |
| 10 | path string |
| 11 | cmdCount int |
| 12 | createCount int |
| 13 | stopCount int |
| 14 | sendCount int |
| 15 | }{ |
| 16 | {"hello01.go", 5, 2, 2, 1}, |
| 17 | {"pingpong01.go", 16, 3, 1, 12}, |
| 18 | {"pingpong02.go", 18, 4, 1, 13}, |
| 19 | {"pingpong03.go", 212, 101, 1, 110}, |
| 20 | {"fanin1.go", 48, 4, 4, 40}, |
| 21 | {"workers1.go", 126, 38, 38, 50}, |
| 22 | {"workers2.go", 346, 66, 60, 220}, |
| 23 | {"server1.go", 5, 3, 2, 0}, |
| 24 | {"primesieve.go", 188, 12, 1, 175}, |
| 25 | //{"select.go", 24, 3, 3, 0}, |
| 26 | } |
| 27 | |
| 28 | for _, test := range tests { |
| 29 | path := filepath.Join("examples", test.path) |
| 30 | t.Log("Testing", path) |
| 31 | src := NewNativeRun(path) |
| 32 | events, err := src.Events() |
| 33 | if err != nil { |
| 34 | t.Fatal(path, err) |
| 35 | } |
| 36 | commands, err := ConvertEvents(events) |
| 37 | if err != nil { |
| 38 | t.Fatal(path, err) |
| 39 | } |
| 40 | |
| 41 | if commands.Count() != test.cmdCount { |
| 42 | t.Fatalf("Wrong number of commands: %s: expecting %d, but got %d", path, test.cmdCount, commands.Count()) |
| 43 | } |
| 44 | if commands.CountCreateGoroutine() != test.createCount { |
| 45 | t.Fatalf("Wrong number of Create commands: %s: expecting %d, but got %d", path, test.createCount, commands.CountCreateGoroutine()) |
| 46 | } |
| 47 | if commands.CountStopGoroutine() != test.stopCount { |
| 48 | t.Fatalf("Wrong number of Stop commands: %s: expecting %d, but got %d", path, test.stopCount, commands.CountStopGoroutine()) |
| 49 | } |
| 50 | if commands.CountSendToChannel() != test.sendCount { |
| 51 | t.Fatalf("Wrong number of Send commands: %s: expecting %d, but got %d", path, test.sendCount, commands.CountSendToChannel()) |
| 52 | } |
| 53 | } |
| 54 | } |
nothing calls this directly
no test coverage detected