(t *testing.T)
| 34 | } |
| 35 | |
| 36 | func TestTopological(t *testing.T) { |
| 37 | for _, tc := range testCases { |
| 38 | t.Run(tc.name, func(t *testing.T) { |
| 39 | actual := Topological(tc.N, tc.constraints) |
| 40 | |
| 41 | visited := make([]bool, tc.N) |
| 42 | positions := make([]int, tc.N) |
| 43 | for i := 0; i < tc.N; i++ { |
| 44 | positions[actual[i]] = i |
| 45 | visited[actual[i]] = true |
| 46 | } |
| 47 | for _, v := range visited { |
| 48 | if !v { |
| 49 | t.Errorf("nodes not all visited, %v", visited) |
| 50 | } |
| 51 | } |
| 52 | for _, c := range tc.constraints { |
| 53 | if positions[c[0]] > positions[c[1]] { |
| 54 | t.Errorf("%v dun satisfy %v", actual, c) |
| 55 | } |
| 56 | } |
| 57 | }) |
| 58 | } |
| 59 | } |
nothing calls this directly
no test coverage detected