def test_get_silent_and_listen(): hashtable = Hashtable() hashtable.set('listen', 'to me') hashtable.set('silent', 'so quiet') assert hashtable.get('listen') == 'to me' assert hashtable.get('silent') == 'so quiet'
def test_hashtable_contains_true(): hashtable = Hashtable() hashtable.set('listen',1) actual = hashtable.contains('listen') expected = True assert actual == expected
def test_hashtable_returns_null(): hashtable = Hashtable() hashtable.set('glisten',3) actual = hashtable.get('cat') expected = False assert actual == expected
def test_hashtable_add(): hashtable = Hashtable() hashtable.set('glisten',3) actual = hashtable.get('glisten') expected = 3 assert actual == expected
def test_hashtable_lookup_collision(): hashtable = Hashtable() hashtable.set('listen', 1) hashtable.set('silent', 2) actual = hashtable.get('listen') expected = 1 assert actual == expected
def repeated_word_check(text_to_check): case_format = text_to_check.lower() punctuation_clean = case_format.translate( str.maketrans('', '', string.punctuation)) iterable_words = punctuation_clean.split() ht = Hashtable() for word in iterable_words: if ht.contains(word): return word else: ht.set(word, word) return 'No Words Repeated'
def test_get_apple(): hashtable = Hashtable() hashtable.set("apple", "Used for apple sauce") actual = hashtable.get("apple") expected = "Used for apple sauce" assert actual == expected