Ejemplo n.º 1
0
def test_in_range_hash():
    hashtable = Hashtable()
    actual = hashtable._hash('spam')

    # assert actual >= 0
    # assert actual < hashtable._size

    assert 0 <= actual < hashtable._size
Ejemplo n.º 2
0
    hashmap1 = Hashtable()
    hashmap2 = Hashtable()

    # hashmap1.add('fond', 'enamored')
    # hashmap1.add('wrath', 'anger')
    # hashmap1.add('diligent', 'employed')
    # hashmap1.add('outfit', 'garb')
    # hashmap1.add('guide', 'usher')

    # hashmap2.add('fond', 'averse')
    # hashmap2.add('wrath', 'delight')
    # hashmap2.add('diligent', 'idle')
    # hashmap2.add('guide', 'follow')
    # hashmap2.add('flow', 'jam')

    # print(left_joiner(hashmap1, hashmap2))

    print('Hashmap1 Key Indices')
    print('fond:', hashmap1._hash('fond'))
    print('wrath:', hashmap1._hash('wrath'))
    print('diligent:', hashmap1._hash('diligent'))
    print('outfit:', hashmap1._hash('outfit'))
    print('guide:', hashmap1._hash('guide'))

    print('Hashmap2 Key Indices')
    print('fond:', hashmap2._hash('fond'))
    print('wrath:', hashmap2._hash('wrath'))
    print('diligent:', hashmap2._hash('diligent'))
    print('guide:', hashmap2._hash('guide'))
    print('flow:', hashmap2._hash('flow'))
Ejemplo n.º 3
0
def test_predictable_hash():
    hashtable = Hashtable()
    initial = hashtable._hash('spam')
    secondary = hashtable._hash('spam')
    assert initial == secondary
Ejemplo n.º 4
0
def test_different_hash():
    hashtable = Hashtable()
    initial = hashtable._hash('glisten')
    secondary = hashtable._hash('silent')
    assert initial != secondary
Ejemplo n.º 5
0
def test_same_hash():
    hashtable = Hashtable()
    initial = hashtable._hash('listen')
    secondary = hashtable._hash('silent')
    assert initial == secondary