(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestDfsWhenPathIsFound(t *testing.T) { |
| 9 | nodes := []int{ |
| 10 | 1, 2, 3, 4, 5, 6, |
| 11 | } |
| 12 | |
| 13 | //Adjacency Matrix for connected nodes |
| 14 | edges := [][]bool{ |
| 15 | {false, true, true, false, false, false}, |
| 16 | {true, false, false, true, false, false}, |
| 17 | {true, false, false, true, false, false}, |
| 18 | {false, true, true, false, true, false}, |
| 19 | {false, false, false, true, false, true}, |
| 20 | {false, false, false, false, true, false}, |
| 21 | } |
| 22 | |
| 23 | start := 1 |
| 24 | end := 6 |
| 25 | |
| 26 | actual, actualIsFound := DepthFirstSearch(start, end, nodes, edges) |
| 27 | expected := []int{1, 3, 4, 5, 6} |
| 28 | expectedIsFound := true |
| 29 | t.Run("Test Dfs", func(t *testing.T) { |
| 30 | if !reflect.DeepEqual(expected, actual) || !reflect.DeepEqual(actualIsFound, expectedIsFound) { |
| 31 | t.Errorf("got route: %v, want route: %v", actual, expected) |
| 32 | t.Errorf("got isFound: %v, want isFound: %v", actualIsFound, expectedIsFound) |
| 33 | } |
| 34 | }) |
| 35 | } |
| 36 | |
| 37 | func TestDfsWhenPathIsNotFound(t *testing.T) { |
| 38 | nodes := []int{ |
nothing calls this directly
no test coverage detected