Пример #1
0
 def test_increaseSize(self):
     testCase = ArrayBasedList(4)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     testCase.append(7)
     self.assertEqual(testCase.__len__(), 5)
     self.assertNotEqual(testCase.__len__(), 6)
Пример #2
0
 def test_insert(self):
     testCase = ArrayBasedList(10)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     testCase.insert(1, 2)
     self.assertEqual(testCase.__str__(), "2\n3\n4\n5\n6\n")
     self.assertRaises(IndexError, testCase.insert, 7, 2)
Пример #3
0
 def test_remove(self):
     testCase = ArrayBasedList(10)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     testCase.remove(3)
     self.assertEqual(testCase.__str__(), "4\n5\n6\n")
     self.assertRaises(ValueError, testCase.remove, 5)
Пример #4
0
 def test_delete(self):
     testCase = ArrayBasedList(10)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     testCase.delete(1)
     self.assertEqual(testCase.__str__(), "4\n5\n6\n")
     self.assertRaises(IndexError, testCase.delete, 5)
Пример #5
0
 def test__str__(self):
     testCase = ArrayBasedList(10)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     self.assertEqual(testCase.__str__(), "3\n4\n5\n6\n")
     self.assertNotEqual(testCase.__str__(), "3\n4\n6\n")
Пример #6
0
 def test_isFull(self):
     testCase = ArrayBasedList(4)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     self.assertEqual(testCase.isFull(), True)
     self.assertNotEqual(testCase.isFull(), False)
Пример #7
0
 def test__len__(self):
     testCase = ArrayBasedList(10)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     self.assertEqual(testCase.__len__(), 4)
     self.assertNotEqual(testCase.__len__(), 3)
Пример #8
0
 def test__eq__(self):
     testCase = ArrayBasedList(10)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     other = [3, 4, 5, 6]
     self.assertEqual(testCase.__eq__(other), True)
     other = [1, 2, 3, 4]
     self.assertNotEqual(testCase.__eq__(other), True)
Пример #9
0
 def test_getitem__(self):
     testCase = ArrayBasedList(10)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     self.assertEqual(testCase.__getitem__(4), 6)
     self.assertRaises(IndexError, testCase.__getitem__, 5)
Пример #10
0
 def test__contains__(self):
     testCase = ArrayBasedList(10)
     testCase.append(3)
     testCase.append(4)
     testCase.append(5)
     testCase.append(6)
     self.assertEqual(testCase.__contains__(3), True)
     self.assertEqual(testCase.__contains__(7), False)