Ejemplo n.º 1
0
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'
Ejemplo n.º 2
0
def test_hashtable_contains_true():
    hashtable = Hashtable()
    hashtable.set('listen',1)

    actual = hashtable.contains('listen')
    expected = True

    assert actual == expected
Ejemplo n.º 3
0
def test_hashtable_returns_null():
    hashtable = Hashtable()
    hashtable.set('glisten',3)

    actual = hashtable.get('cat')

    expected = False

    assert actual == expected
Ejemplo n.º 4
0
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
Ejemplo n.º 6
0
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'
Ejemplo n.º 7
0
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