Exemple #1
0
 def test_rotate_insert_rotate_back_3(self):
     expected = CircularList().from_iterable([1, 2, 3, 4, 5, 6, 7, 8, 9])
     actual = CircularList().from_iterable([1, 2, 3, 4, 5, 6, 7, 9])
     actual.rotate(-6)
     actual.insert_at_cursor(8)
     actual.rotate(7)
     self.assertEqual(expected, actual)
Exemple #2
0
 def test_pop_and_insert_1(self):
     expected = CircularList().from_iterable([1, 2, 3, 4, 5, 6, 7, 8, 9])
     actual = CircularList().from_iterable([9, 2, 3, 4, 5, 6, 7, 8, 1])
     actual.rotate(-8)
     popped = actual.pop_at()
     actual.insert_at_cursor(popped)
     self.assertEqual(expected, actual)
Exemple #3
0
 def test_str_non_empty(self):
     cl = CircularList.from_iterable([1, 2, 3])
     actual = io.StringIO()
     with redirect_stdout(actual):
         print(cl, end='')
     expected = 'CircularList((1), 2, 3)'
     self.assertEqual(actual.getvalue(), expected)
Exemple #4
0
 def test_type(self):
     self.assertIsInstance(CircularList(), CircularList)
Exemple #5
0
 def test_rotate_minus_1(self):
     expected = CircularList().from_iterable([1, 2, 3, 4, 0])
     actual = CircularList().from_iterable(range(5))
     actual.rotate(-1)
     self.assertEqual(expected, actual)
Exemple #6
0
 def test_rotate_2(self):
     expected = CircularList().from_iterable([4, 0, 1, 2, 3])
     actual = CircularList().from_iterable(range(5))
     actual.rotate(1)
     self.assertEqual(expected, actual)
Exemple #7
0
 def test_rotate_1(self):
     expected = CircularList().from_iterable([4, 0, 1, 2, 3])
     actual = CircularList().from_iterable(range(5))
     actual.rotate()  # test default parameter
     self.assertEqual(expected, actual)
Exemple #8
0
 def test_equality_empty(self):
     cl1 = CircularList()
     cl2 = CircularList()
     self.assertTrue(cl1 == cl2)
Exemple #9
0
 def test_equality(self):
     cl1 = CircularList.from_iterable(range(4))
     cl2 = CircularList.from_iterable([0, 1, 2, 3])
     self.assertTrue(cl1 == cl2)
Exemple #10
0
 def test_truthfulness_2(self):
     cl = CircularList.from_iterable([1, 2, 5, 8, 9])
     self.assertTrue(cl)
Exemple #11
0
 def test_truthfulness_1(self):
     cl = CircularList.from_iterable([-1])
     self.assertTrue(cl)
Exemple #12
0
 def test_truthfulness_empty_container(self):
     cl = CircularList.from_iterable([])
     self.assertFalse(cl)
Exemple #13
0
 def test_from_iterable_2(self):
     cl = CircularList.from_iterable([1, 2, 5, 8, 9])
     self.assertEqual(len(cl), 5)
Exemple #14
0
 def test_from_iterable_1(self):
     cl = CircularList.from_iterable([1])
     self.assertEqual(len(cl), 1)
Exemple #15
0
 def test_from_iterable_empty(self):
     cl = CircularList.from_iterable([])
     self.assertEqual(len(cl), 0)
Exemple #16
0
 def test_rotate_minus_len(self):
     expected = CircularList().from_iterable([0, 1, 2, 3, 4])
     actual = CircularList().from_iterable(range(5))
     actual.rotate(-len(actual))
     self.assertEqual(expected, actual)
Exemple #17
0
 def test_rotate_3(self):
     expected = CircularList().from_iterable([2, 3, 4, 0, 1])
     actual = CircularList().from_iterable(range(5))
     actual.rotate(3)
     self.assertEqual(expected, actual)
Exemple #18
0
 def test_len_0(self):
     self.assertEqual(len(CircularList()), 0)