Exemplo n.º 1
0
def test_remove_node(create_full_cache):
    tmp_cache = create_full_cache
    assert tmp_cache._tail == tmp_cache._dict[1]
    tmp_cache.remove_last_node()
    assert tmp_cache._dict[2] == tmp_cache._tail
    assert tmp_cache._dict.get(1, "NODATA") == "NODATA"

    tmp2_cache = LRUCache()
    tmp2_cache.set(20)
    tmp2_cache.set(21)
    tmp2_cache.remove_last_node()
    assert tmp2_cache._head == tmp2_cache._dict[21]
    assert tmp2_cache._tail == None
    tmp2_cache.remove_last_node()
    assert tmp2_cache._head == None
    assert tmp2_cache._tail == None