Пример #1
0
    def test_add_by_value_to_empty(self):
        """Test adding multiple items to an empty bimap by value."""
        bimap = BiMap()
        bimap.update_by_value({"first": 1, "second": 2})

        self.assertEqual(2, len(bimap))
        self.assertEqual("first", bimap.get_key(1))
        self.assertEqual(2, bimap.get_value("second"))
Пример #2
0
    def test_add_to_nonempty(self):
        """Test adding multiple items to nonempty bimap."""
        bimap = BiMap({1: "first", 2: "second"})
        bimap.update_by_value({"third": 3, "fourth": 4})
        bimap.update_by_key({2: "secondNew", 3: "thirdNew"})

        self.assertEqual(4, len(bimap))
        self.assertEqual("first", bimap.get_key(1))
        self.assertEqual("secondNew", bimap.get_key(2))
        self.assertEqual(3, bimap.get_value("thirdNew"))
        self.assertEqual(4, bimap.get_value("fourth"))