Mercurial > lcfOS
view 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 |
line wrap: on
line source
#!/usr/bin/python import unittest import graph class GraphTestCase(unittest.TestCase): def testEdge(self): g = graph.Graph() n1 = graph.Node(g) g.addNode(n1) n2 = graph.Node(g) g.addNode(n2) g.addEdge(n1, n2) self.assertTrue(g.hasEdge(n2, n1)) self.assertTrue(g.hasEdge(n1, n2)) g.delNode(n1) g.delNode(n2) def testDegree(self): g = graph.Graph() n1 = graph.Node(g) g.addNode(n1) n2 = graph.Node(g) g.addNode(n2) n3 = graph.Node(g) g.addNode(n3) g.addEdge(n1, n2) g.addEdge(n1, n3) self.assertEqual(2, n1.Degree) self.assertEqual(1, n2.Degree) g.delNode(n2) self.assertEqual(1, n1.Degree) class DigraphTestCase(unittest.TestCase): pass if __name__ == '__main__': unittest.main()