def test_iteration_resolution_chaining(self): # Arrange ht = HashTable(container_type=LinkedList, resolution=HashTable.RESOLUTION_CHAINING, hash_function=lambda x: 1) ht.insert('key', 'value') ht.insert('key2', 'value2') ht.hash_function = lambda x: 2 ht.insert('key3', 'value3') # Act + Assert for (expected_key, expected_val), (actual_key, actual_val) in zip((('key', 'value'), ('key2', 'value2'), ('key3', 'value3')), ht): self.assertEqual(expected_key, actual_key) self.assertEqual(expected_val, actual_val)
def test_iteration_resolution_overwrite(self): # Arrange ht = HashTable() ht.insert('key', 'value') ht.insert('key2', 'value2') ht.hash_function = lambda x: 2 ht.insert('key3', 'value3') # Act + Assert for (expected_key, expected_val), (actual_key, actual_val) in zip((('key3', 'value3'), ('key2', 'value2'), ('key', 'value')), ht): self.assertEqual(expected_key, actual_key) self.assertEqual(expected_val, actual_val)