comparison python/testgraph.py @ 277:046017431c6a

Started register allocator
author Windel Bouwman
date Thu, 26 Sep 2013 21:14:25 +0200
parents
children 9fca39eebe50
comparison
equal deleted inserted replaced
276:56d37ed4b4d2 277:046017431c6a
1 #!/usr/bin/python
2
3 import unittest
4 import graph
5
6 class GraphTestCase(unittest.TestCase):
7 def testEdge(self):
8 g = graph.Graph(False)
9 n1 = g.newNode()
10 n2 = g.newNode()
11 g.addEdge(n1, n2)
12 self.assertTrue(g.hasEdge(n2, n1))
13 self.assertTrue(g.hasEdge(n1, n2))
14 g.delNode(n1)
15 g.delNode(n2)
16
17 def testDegree(self):
18 g = graph.Graph(False)
19 n1 = g.newNode()
20 n2 = g.newNode()
21 n3 = g.newNode()
22 g.addEdge(n1, n2)
23 g.addEdge(n1, n3)
24 self.assertEqual(2, n1.Degree)
25 self.assertEqual(1, n2.Degree)
26 g.delNode(n2)
27 self.assertEqual(1, n1.Degree)
28
29 class DigraphTestCase(unittest.TestCase):
30 pass
31
32
33 if __name__ == '__main__':
34 unittest.main()
35