예제 #1
0
 def test_diamond(self):
     s = dedent("""\
              A o
             A:1,2,3,4
             """)
     expected = [[1, 0, 1, 2, 3, 4]]
     self.assertEqual(bridge.load_string(s)[1], expected)
예제 #2
0
 def test_multiline(self):
     s = dedent("""\
         o o o
          o o
           o
         """)
     expected = [(0, 0), (2, 0), (4, 0), (1, 1), (3, 1), (2, 2)]
     self.assertEqual(bridge.load_string(s)[0], expected)
예제 #3
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]))
예제 #4
0
 def test_diamonds(self):
     s = dedent("""\
              A o
             o  B
             A:11,12,13,14
             B:9,8,7,6
             """)
     expected = [[1, 0, 11, 12, 13, 14], [3, 1, 9, 8, 7, 6]]
     self.assertEqual(bridge.load_string(s)[1], expected)
예제 #5
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]))
예제 #6
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)))
예제 #7
0
 def test_oneline(self):
     s = "o o  o"
     expected = [(0, 0), (2, 0), (5, 0)]
     self.assertEqual(bridge.load_string(s)[0], expected)