Exemple #1
0
 def test_contiguous2(self):
     s = """\
      o
     oo
     """
     node_data, _ = bridge.load_string(dedent(s))
     nodes = bridge.make_nodes(node_data)
     edges = sorted(bridge.make_edges(nodes, []).values())
     self.assertFalse(bridge.edges_cross(edges[1], edges[0]))
Exemple #2
0
 def test_disjoint3(self):
     s = """\
      oo
     o
     o
     """
     node_data, _ = bridge.load_string(dedent(s))
     nodes = bridge.make_nodes(node_data)
     edges = bridge.make_edges(nodes, []).values()
     self.assertFalse(bridge.edges_cross(edges[1], edges[0]))
Exemple #3
0
 def test_1(self):
     s = """\
     o oo 
     o  o  o
       o o
     """
     node_data, _ = bridge.load_string(dedent(s))
     nodes = bridge.make_nodes(node_data)
     edges = bridge.make_edges(nodes, [])
     crosses = bridge.find_crosses(edges)
     self.assertEquals(len(crosses), 1)
     cross = crosses[0]
     self.assertEquals(cross[0].range, r((0, 3), (1, 1)))
     self.assertEquals(cross[1].range, r((2, 2), (0, 2)))
Exemple #4
0
 def test_nodes(self):
     node_data = [(0, 0), (2, 0), (3, 0), (0, 1), (3, 1), (2, 2)]
     expected = {
         (0, 0): ((0, 1), (2, 0)),
         (2, 0): ((0, 0), (2, 2), (3, 0)),
         (3, 0): ((2, 0), (3, 1)),
         (0, 1): ((0, 0), (3, 1)),
         (3, 1): ((0, 1), (3, 0)),
         (2, 2): ((2, 0), )
     }
     nodes = bridge.make_nodes(node_data)
     e = bridge.make_edges(nodes, [])
     self.assertEqual(len(e), 6)
     for k, v in expected.iteritems():
         n = nodes[k]
         self.assertEqual(len(n.edges), len(v))
Exemple #5
0
 def test_diamonds(self):
     node_data = [(0, 0), (2, 0), (3, 0), (0, 1), (3, 1), (2, 2)]
     diamond_data = [(1, 0, 0, 0, 0, 0), (2, 1, 0, 0, 0, 0)]
     expected = {
         (0, 0): ((0, 1), ),
         (2, 0): ((3, 0), ),
         (3, 0): ((2, 0), (3, 1)),
         (0, 1): ((0, 0), ),
         (3, 1): ((0, 1), ),
         (2, 2): ()
     }
     nodes = bridge.make_nodes(node_data)
     diamonds = bridge.make_diamonds(diamond_data)
     e = bridge.make_edges(nodes, diamond_data)
     self.assertEqual(len(e), 3)
     for k, v in expected.iteritems():
         n = nodes[k]
         self.assertEqual(len(n.edges), len(v))