Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 3
0
 def test_type(self):
     self.assertIsInstance(DoublyLinkedList(), DoublyLinkedList)
Exemplo n.º 4
0
 def test_equality_empty(self):
     dl1 = DoublyLinkedList()
     dl2 = DoublyLinkedList()
     self.assertTrue(dl1 == dl2)
Exemplo n.º 5
0
 def test_equality(self):
     dl1 = DoublyLinkedList.from_iterable(range(4))
     dl2 = DoublyLinkedList.from_iterable([0, 1, 2, 3])
     self.assertTrue(dl1 == dl2)
Exemplo n.º 6
0
 def test_truthfulness_1(self):
     dl = DoublyLinkedList.from_iterable([-1])
     self.assertTrue(dl)
Exemplo n.º 7
0
 def test_truthfulness_2(self):
     dl = DoublyLinkedList.from_iterable([1, 2, 5, 8, 9])
     self.assertTrue(dl)
Exemplo n.º 8
0
 def test_truthfulness_empty_container(self):
     dl = DoublyLinkedList.from_iterable([])
     self.assertFalse(dl)
Exemplo n.º 9
0
 def test_from_iterable_2(self):
     dl = DoublyLinkedList.from_iterable([1, 2, 5, 8, 9])
     self.assertEqual(len(dl), 5)
Exemplo n.º 10
0
 def test_from_iterable_1(self):
     dl = DoublyLinkedList.from_iterable([1])
     self.assertEqual(len(dl), 1)
Exemplo n.º 11
0
 def test_from_iterable_empty(self):
     dl = DoublyLinkedList.from_iterable([])
     self.assertEqual(len(dl), 0)
Exemplo n.º 12
0
 def test_len_0(self):
     self.assertEqual(len(DoublyLinkedList()), 0)