mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-09 19:08:02 +00:00
Added remove duplicates challenge.
This commit is contained in:
36
linked_lists/remove_duplicates/test_remove_duplicates.py
Normal file
36
linked_lists/remove_duplicates/test_remove_duplicates.py
Normal file
@@ -0,0 +1,36 @@
|
||||
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(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()
|
||||
Reference in New Issue
Block a user