def test_add_by_value_to_empty(self): """Test adding a single item to empty bimap by value.""" bimap = BiMap() bimap.add_value("first", 1) self.assertEqual({1: "first"}, bimap.get_key_to_value()) self.assertEqual(1, len(bimap)) self.assertEqual(1, bimap.get_value("first")) self.assertEqual("first", bimap.get_key(1))
def test_add_to_nonempty(self): """Test adding a single item to nonempty bimap.""" bimap = BiMap({1: "first", 2: "second"}) bimap.add_key(3, "third") bimap.add_value("fourth", 4) self.assertEqual(4, len(bimap)) self.assertEqual("second", bimap.get_key(2)) self.assertEqual("fourth", bimap.get_key(4)) self.assertEqual(3, bimap.get_value("third"))