def test_primitives():
    dictionnary = Dictionnary()
    with pytest.raises(NotImplementedError):
        dictionnary.search(key=0)
    with pytest.raises(NotImplementedError):
        dictionnary.insert(KeyedItem(0, 0))
    with pytest.raises(NotImplementedError):
        dictionnary.delete(KeyedItem(0, 0))
    with pytest.raises(NotImplementedError):
        dictionnary.max()
    with pytest.raises(NotImplementedError):
        dictionnary.min()
    with pytest.raises(NotImplementedError):
        dictionnary.predecessor(KeyedItem(0, 0))
    with pytest.raises(NotImplementedError):
        dictionnary.successor(KeyedItem(0, 0))
def test_search_balanced_tree():
    dictionnary = Dictionnary(implementation='balanced_tree')
    item_0 = KeyedItem(key=0, content=0)
    item_1 = KeyedItem(key=1, content=1)
    item_2 = KeyedItem(key=2, content=2)
    item_3 = KeyedItem(key=3, content=3)
    item_4 = KeyedItem(key=4, content=4)
    dictionnary.insert(item_0)
    assert dictionnary.search(key=0) is item_0
    dictionnary.insert(item_3)
    dictionnary.insert(item_1)
    dictionnary.insert(item_4)
    dictionnary.insert(item_2)
    assert dictionnary.search(key=0) is item_0
    assert dictionnary.search(key=1) is item_1
    assert dictionnary.search(key=2) is item_2
    assert dictionnary.search(key=3) is item_3
    assert dictionnary.search(key=4) is item_4
def test_search_doubly_unsorted():
    dictionnary = Dictionnary(implementation='doubly_unsorted')
    item_0 = KeyedItem(key=0, content=0)
    item_1 = KeyedItem(key=1, content=1)
    item_2 = KeyedItem(key=2, content=2)
    item_3 = KeyedItem(key=3, content=3)
    item_4 = KeyedItem(key=4, content=4)
    dictionnary.insert(item_0)
    assert dictionnary.search(key=0) is item_0
    dictionnary.insert(item_3)
    dictionnary.insert(item_1)
    dictionnary.insert(item_4)
    dictionnary.insert(item_2)
    assert dictionnary.search(key=0) is item_0
    assert dictionnary.search(key=1) is item_1
    assert dictionnary.search(key=2) is item_2
    assert dictionnary.search(key=3) is item_3
    assert dictionnary.search(key=4) is item_4
def test_search_fail_balanced_tree():
    dictionnary = Dictionnary(implementation='balanced_tree')
    item = KeyedItem(key=0, content=0)
    dictionnary.insert(item)
    with pytest.raises(FileNotFoundError):
        dictionnary.search(key=1)
def test_search_fail_empty_balanced_tree():
    dictionnary = Dictionnary(implementation='balanced_tree')
    with pytest.raises(FileNotFoundError):
        dictionnary.search(key=0)
def test_search_fail_doubly_sorted():
    dictionnary = Dictionnary(implementation='doubly_sorted')
    item = KeyedItem(key=0, content=0)
    dictionnary.insert(item)
    with pytest.raises(FileNotFoundError):
        dictionnary.search(key=1)
def test_search_fail_empty_doubly_sorted():
    dictionnary = Dictionnary(implementation='doubly_sorted')
    with pytest.raises(FileNotFoundError):
        dictionnary.search(key=0)
def test_search_fail_empty_unsorted_array():
    dictionnary = Dictionnary(implementation='unsorted_array')
    with pytest.raises(FileNotFoundError):
        dictionnary.search(key=0)
def test_search_unsorted_array():
    dictionnary = Dictionnary(implementation='unsorted_array')
    item = KeyedItem(key=0, content=0)
    dictionnary.insert(item)
    assert dictionnary.search(key=0) is item