def setUp(self): trk_array = [ Track(direction='Y', x_low=1, x_high=1, y_low=1, y_high=5), Track(direction='X', x_low=1, x_high=3, y_low=1, y_high=1), Track(direction='Y', x_low=3, x_high=3, y_low=1, y_high=4), ] cnx_array = [(0, 1), (1, 2)] self.trks = Tracks(trk_array, cnx_array)
def test_adjacenet_assert(self): trk_array = [ Track(direction='Y', x_low=1, x_high=1, y_low=1, y_high=5), Track(direction='X', x_low=1, x_high=3, y_low=1, y_high=1), Track(direction='foobar', x_low=3, x_high=3, y_low=1, y_high=4), ] cnx_array = [(0, 1), (1, 2)] trks = Tracks(trk_array, cnx_array) with self.assertRaises(AssertionError): trks.is_wire_adjacent_to_track(2, (3, 1))
def test_verify_tracks_directon_error(self): self.trks.tracks.append( Track(direction='Y', x_low=1, x_high=1, y_low=5, y_high=6)) self.trks.track_connections.append((0, 3)) with self.assertRaises(AssertionError): self.trks.verify_tracks()
def test_check_ptc(self): self.graph.check_ptc() trk = Track(direction='Y', x_low=2, x_high=2, y_low=1, y_high=3) segment_id = -1 self.graph.add_track(trk, segment_id) with self.assertRaises(AssertionError): self.graph.check_ptc()
def test_add_edge(self): trk = Track(direction='Y', x_low=2, x_high=2, y_low=1, y_high=3) segment_id = -1 self.graph.add_track(trk, segment_id) trk = Track(direction='X', x_low=1, x_high=3, y_low=1, y_high=1) segment_id = -1 self.graph.add_track(trk, segment_id) trk = Track(direction='X', x_low=1, x_high=3, y_low=3, y_high=3) segment_id = -1 self.graph.add_track(trk, segment_id) idx = self.graph.add_edge(1, 2, 0) self.assertEqual(self.graph.edges[idx].src_node, 1) self.assertEqual(self.graph.edges[idx].sink_node, 2) self.assertEqual(self.graph.edges[idx].switch_id, 0) self.assertEqual(self.graph.edges[idx].metadata, None)
def test_add_track(self): trk = Track(direction='Y', x_low=2, x_high=2, y_low=1, y_high=3) segment_id = -1 node_id = self.graph.add_track(trk, segment_id) self.assertEqual(len(self.graph.tracks), 1) self.assertEqual(len(self.graph.nodes), 1) node = self.graph.nodes[node_id] self.assertEqual(node.id, len(self.graph.nodes) - 1) self.assertEqual(node.type, NodeType.CHANY) self.assertEqual(node.direction, NodeDirection.BI_DIR) self.assertEqual(node.capacity, 1)
def test_verify_tracks_not_connected(self): self.trks.tracks.append( Track(direction='X', x_low=1, x_high=3, y_low=4, y_high=4)) with self.assertRaises(AssertionError): self.trks.verify_tracks()