Example #1
0
 def test_reversed_via_str_non_empty(self):
     dl = DoublyLinkedList.from_iterable(range(4))
     actual = io.StringIO()
     with redirect_stdout(actual):
         print(DoublyLinkedList.from_iterable(reversed(dl)), end='')
     expected = 'DoublyLinkedList(3 <-> 2 <-> 1 <-> 0)'
     self.assertEqual(actual.getvalue(), expected)
Example #2
0
 def test_str_non_empty(self):
     dl = DoublyLinkedList.from_iterable([1, 2, 3])
     actual = io.StringIO()
     with redirect_stdout(actual):
         print(dl, end='')
     expected = 'DoublyLinkedList(1 <-> 2 <-> 3)'
     self.assertEqual(actual.getvalue(), expected)
Example #3
0
 def test_equality(self):
     dl1 = DoublyLinkedList.from_iterable(range(4))
     dl2 = DoublyLinkedList.from_iterable([0, 1, 2, 3])
     self.assertTrue(dl1 == dl2)
Example #4
0
 def test_truthfulness_2(self):
     dl = DoublyLinkedList.from_iterable([1, 2, 5, 8, 9])
     self.assertTrue(dl)
Example #5
0
 def test_truthfulness_1(self):
     dl = DoublyLinkedList.from_iterable([-1])
     self.assertTrue(dl)
Example #6
0
 def test_truthfulness_empty_container(self):
     dl = DoublyLinkedList.from_iterable([])
     self.assertFalse(dl)
Example #7
0
 def test_from_iterable_2(self):
     dl = DoublyLinkedList.from_iterable([1, 2, 5, 8, 9])
     self.assertEqual(len(dl), 5)
Example #8
0
 def test_from_iterable_1(self):
     dl = DoublyLinkedList.from_iterable([1])
     self.assertEqual(len(dl), 1)
Example #9
0
 def test_from_iterable_empty(self):
     dl = DoublyLinkedList.from_iterable([])
     self.assertEqual(len(dl), 0)