コード例 #1
0
 def test_example(self):
     assert set(map(str, Bridge.all_bridges_from_component_strings(
         COMPONENT_STRINGS))) == {'0/1', '0/1--10/1', '0/1--10/1--9/10',
                                  '0/2', '0/2--2/3', '0/2--2/3--3/4',
                                  '0/2--2/3--3/5', '0/2--2/2',
                                  '0/2--2/2--2/3', '0/2--2/2--2/3--3/4',
                                  '0/2--2/2--2/3--3/5'}
コード例 #2
0
    def test_compatible(self):
        bridge = Bridge()
        assert bridge.compatible(Component.from_string('0/1'))
        assert not bridge.compatible(Component.from_string('1/1'))

        bridge = bridge.add(Component.from_string('0/1'))
        assert bridge.compatible(Component.from_string('2/1'))
        assert bridge.compatible(Component.from_string('1/2'))
コード例 #3
0
 def test_example(self):
     assert Bridge.strength_of_longest_bridge(COMPONENT_STRINGS) == 19
コード例 #4
0
 def test_strongest_bridge_from_components_strings(self):
     assert Bridge.strongest_bridge_from_component_strings(
         COMPONENT_STRINGS) == 31
コード例 #5
0
 def test_two_parallel(self):
     assert set(map(str, Bridge._all_bridges_from_components([
         Component.from_string('0/1'), Component.from_string('0/2')]))) == \
            {'0/1', '0/2'}
コード例 #6
0
 def test_single_incompatible(self):
     assert set(map(str, Bridge._all_bridges_from_components([
         Component.from_string('1/1')]))) == set()
コード例 #7
0
 def test_single(self):
     assert set(map(str, Bridge._all_bridges_from_components([
         Component.from_string('0/1')]))) == {'0/1'}
コード例 #8
0
 def test_empty(self):
     assert list(Bridge._all_bridges_from_components([])) == []
コード例 #9
0
 def test_str(self):
     bridge = Bridge()
     bridge = bridge.add(Component.from_string('0/1'))
     bridge = bridge.add(Component.from_string('10/1'))
     assert str(bridge) == '0/1--10/1'