Skip to content

Commit

Permalink
added differentiated tests for clearing directed and undirected graph
Browse files Browse the repository at this point in the history
  • Loading branch information
eileen-kuehn committed Jul 27, 2018
1 parent 7772227 commit bb5d05b
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions graphi_unittests/types_unittests/test_adjacency_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def test_update(self):
self.assertIn(5, graph)
self.assertIn(6, graph)

def test_clear(self):
def test_clear_undirected(self):
graph = Undirected(self.graph_cls({
1: {2: 1, 3: 1, 4: 1},
2: {1: 1},
Expand All @@ -238,6 +238,17 @@ def test_clear(self):
graph.clear()
self.assertEquals(len(graph), 0)

def test_clear_directed(self):
graph = self.graph_cls({
1: {2: 1, 3: 1, 4: 1},
2: {1: 1},
3: {1: 1},
4: {1: 1}
})
self.assertEquals(len(graph), 4)
graph.clear()
self.assertEquals(len(graph), 0)

def test_edge_view_undirected(self):
graph = Undirected(self.graph_cls({1, 2, 3, 4}))
nodes = [2, 3, 4]
Expand All @@ -260,7 +271,7 @@ def test_edge_view_undirected(self):
None in edge_view

def test_edge_view_directed(self):
graph = self.graph_cls({1, 2, 3, 4, 5}, undirected=False)
graph = self.graph_cls({1, 2, 3, 4, 5})
nodes = [2, 3, 4]
for node in nodes:
graph[1:node] = 1
Expand Down Expand Up @@ -291,7 +302,7 @@ def test_value_view_undirected(self):
self.assertEqual(len(nodes), len(value_view), "The number of values should be half for undirected graphs")

def test_value_view_directed(self):
graph = self.graph_cls({1, 2, 3, 4}, undirected=False)
graph = self.graph_cls({1, 2, 3, 4})
nodes = [2, 3, 4]
for value, node in enumerate(nodes):
graph[1:node] = value
Expand Down

0 comments on commit bb5d05b

Please sign in to comment.