Files
interactive-coding-challenges/linked_lists/remove_duplicates/test_remove_duplicates.py
2016-02-10 06:33:30 -05:00

41 lines
1.1 KiB
Python

from nose.tools import assert_equal
class TestRemoveDupes(object):
def test_remove_dupes(self, linked_list):
print('Test: Empty list')
linked_list.remove_dupes()
assert_equal(linked_list.get_all_data(), [])
print('Test: One element list')
linked_list.insert_to_front(2)
linked_list.remove_dupes()
assert_equal(linked_list.get_all_data(), [2])
print('Test: General case, duplicates')
linked_list.insert_to_front(1)
linked_list.insert_to_front(1)
linked_list.insert_to_front(3)
linked_list.insert_to_front(2)
linked_list.insert_to_front(3)
linked_list.insert_to_front(1)
linked_list.insert_to_front(1)
linked_list.remove_dupes()
assert_equal(linked_list.get_all_data(), [1, 3, 2])
print('Test: General case, no duplicates')
linked_list.remove_dupes()
assert_equal(linked_list.get_all_data(), [1, 3, 2])
print('Success: test_remove_dupes\n')
def main():
test = TestRemoveDupes()
linked_list = MyLinkedList(None)
test.test_remove_dupes(linked_list)
if __name__ == '__main__':
main()