mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-05 00:48:03 +00:00
@@ -1,23 +1,23 @@
|
||||
from nose.tools import assert_equal
|
||||
import unittest
|
||||
|
||||
|
||||
class TestPartition(object):
|
||||
class TestPartition(unittest.TestCase):
|
||||
|
||||
def test_partition(self):
|
||||
print('Test: Empty list')
|
||||
linked_list = MyLinkedList(None)
|
||||
linked_list.partition(10)
|
||||
assert_equal(linked_list.get_all_data(), [])
|
||||
self.assertEqual(linked_list.get_all_data(), [])
|
||||
|
||||
print('Test: One element list, left list empty')
|
||||
linked_list = MyLinkedList(Node(5))
|
||||
linked_list.partition(0)
|
||||
assert_equal(linked_list.get_all_data(), [5])
|
||||
self.assertEqual(linked_list.get_all_data(), [5])
|
||||
|
||||
print('Test: Right list is empty')
|
||||
linked_list = MyLinkedList(Node(5))
|
||||
linked_list.partition(10)
|
||||
assert_equal(linked_list.get_all_data(), [5])
|
||||
self.assertEqual(linked_list.get_all_data(), [5])
|
||||
|
||||
print('Test: General case')
|
||||
# Partition = 10
|
||||
@@ -33,7 +33,7 @@ class TestPartition(object):
|
||||
linked_list.insert_to_front(3)
|
||||
linked_list.insert_to_front(4)
|
||||
partitioned_list = linked_list.partition(10)
|
||||
assert_equal(partitioned_list.get_all_data(),
|
||||
self.assertEqual(partitioned_list.get_all_data(),
|
||||
[4, 3, 8, 1, 10, 10, 13, 14, 12])
|
||||
|
||||
print('Success: test_partition')
|
||||
@@ -45,4 +45,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user