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_delete_unsorted_array(): dictionnary = Dictionnary(implementation='unsorted_array') 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) dictionnary.insert(item_0) dictionnary.insert(item_1) dictionnary.insert(item_2) dictionnary.insert(item_3) dictionnary.delete(item_0) assert dictionnary.min() is item_1 dictionnary.delete(item_1) assert dictionnary.min() is item_2 dictionnary.delete(item_3) assert dictionnary.max() is item_2 dictionnary.delete(item_2) assert dictionnary.min() is None assert dictionnary.max() is None