def test_should_create_hashtable_from_dict_with_custom_capacity(): dictionary = {"hola": "hello", 98.6: 37, False: True} hash_table = HashTable.from_dict(dictionary, capacity=100) assert hash_table.capacity == 100 assert hash_table.keys == set(dictionary.keys()) assert hash_table.pairs == set(dictionary.items()) assert unordered(hash_table.values) == list(dictionary.values())
def test_should_create_hashtable_from_dict(): dictionary = {"hola": "hello", 98.6: 37, False: True} hash_table = HashTable.from_dict(dictionary) assert hash_table.capacity == len(dictionary) * 2 assert hash_table.keys == list(dictionary.keys()) assert hash_table.pairs == list(dictionary.items()) assert hash_table.values == list(dictionary.values())
def test_should_compare_equal_different_capacity(): data = {"a": 1, "b": 2, "c": 3} h1 = HashTable.from_dict(data, capacity=50) h2 = HashTable.from_dict(data, capacity=100) assert h1 == h2
def test_should_compare_unequal(hash_table): other = HashTable.from_dict({"different": "value"}) assert hash_table != other
def test_should_compare_equal_different_key_value_order(hash_table): h1 = HashTable.from_dict({"a": 1, "b": 2, "c": 3}) h2 = HashTable.from_dict({"b": 2, "a": 1, "c": 3}) assert h1 == h2