MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / TestDfsWhenPathIsNotFound

Function TestDfsWhenPathIsNotFound

graph/depthfirstsearch_test.go:37–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

35}
36
37func TestDfsWhenPathIsNotFound(t *testing.T) {
38 nodes := []int{
39 1, 2, 3, 4, 5, 6,
40 }
41
42 //Adjacency Matrix for connected nodes
43 edges := [][]bool{
44 {false, true, true, false, false, false},
45 {true, false, false, true, false, false},
46 {true, false, false, true, false, false},
47 {false, true, true, false, true, false},
48 {false, false, false, true, false, true},
49 {false, false, false, false, true, false},
50 }
51
52 start := 1
53 end := 7
54
55 actual, actualIsFound := DepthFirstSearch(start, end, nodes, edges)
56 var expected []int
57 expectedIsFound := false
58 t.Run("Test Dfs", func(t *testing.T) {
59 if !reflect.DeepEqual(expected, actual) || !reflect.DeepEqual(actualIsFound, expectedIsFound) {
60 t.Errorf("got route: %v, want route: %v", actual, expected)
61 t.Errorf("got isFound: %v, want isFound: %v", actualIsFound, expectedIsFound)
62 }
63 })
64}

Callers

nothing calls this directly

Calls 1

DepthFirstSearchFunction · 0.85

Tested by

no test coverage detected