Mercurial > lcfOS
annotate python/testgraph.py @ 278:9fca39eebe50
First implementation of regalloc with coalsesc
author | Windel Bouwman |
---|---|
date | Sun, 29 Sep 2013 14:08:15 +0200 |
parents | 046017431c6a |
children | 2ccd57b1d78c |
rev | line source |
---|---|
277 | 1 #!/usr/bin/python |
2 | |
3 import unittest | |
4 import graph | |
5 | |
6 class GraphTestCase(unittest.TestCase): | |
7 def testEdge(self): | |
278
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
8 g = graph.Graph() |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
9 n1 = graph.Node(g) |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
10 g.addNode(n1) |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
11 n2 = graph.Node(g) |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
12 g.addNode(n2) |
277 | 13 g.addEdge(n1, n2) |
14 self.assertTrue(g.hasEdge(n2, n1)) | |
15 self.assertTrue(g.hasEdge(n1, n2)) | |
16 g.delNode(n1) | |
17 g.delNode(n2) | |
18 | |
19 def testDegree(self): | |
278
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
20 g = graph.Graph() |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
21 n1 = graph.Node(g) |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
22 g.addNode(n1) |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
23 n2 = graph.Node(g) |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
24 g.addNode(n2) |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
25 n3 = graph.Node(g) |
9fca39eebe50
First implementation of regalloc with coalsesc
Windel Bouwman
parents:
277
diff
changeset
|
26 g.addNode(n3) |
277 | 27 g.addEdge(n1, n2) |
28 g.addEdge(n1, n3) | |
29 self.assertEqual(2, n1.Degree) | |
30 self.assertEqual(1, n2.Degree) | |
31 g.delNode(n2) | |
32 self.assertEqual(1, n1.Degree) | |
33 | |
34 class DigraphTestCase(unittest.TestCase): | |
35 pass | |
36 | |
37 | |
38 if __name__ == '__main__': | |
39 unittest.main() | |
40 |