(t *testing.T)
| 102 | } |
| 103 | |
| 104 | func TestUndirectedGraph(t *testing.T) { |
| 105 | |
| 106 | for _, test := range graphTestCases { |
| 107 | t.Run(fmt.Sprint(test.name), func(t *testing.T) { |
| 108 | // Initializing graph, adding edges |
| 109 | graph := New(test.vertices) |
| 110 | for _, edge := range test.edges { |
| 111 | graph.AddWeightedEdge(edge[0], edge[1], edge[2]) |
| 112 | } |
| 113 | |
| 114 | if graph.vertices != test.vertices { |
| 115 | t.Errorf("Number of vertices, Expected: %d, Computed: %d", test.vertices, graph.vertices) |
| 116 | } |
| 117 | edgeCount := 0 |
| 118 | for _, e := range graph.edges { |
| 119 | edgeCount += len(e) |
| 120 | } |
| 121 | if edgeCount != len(test.edges)*2 { |
| 122 | t.Errorf("Number of edges, Expected: %d, Computed: %d", len(test.edges)*2, edgeCount) |
| 123 | } |
| 124 | for _, edge := range test.edges { |
| 125 | if val, found := graph.edges[edge[0]][edge[1]]; !found || val != edge[2] { |
| 126 | t.Errorf("Edge {%d->%d (%d)} not found", edge[0], edge[1], edge[2]) |
| 127 | } |
| 128 | } |
| 129 | }) |
| 130 | } |
| 131 | } |
nothing calls this directly
no test coverage detected