Exemple #1
0
 def test_ne(self):
     self.assertTrue(MyList(1, 2, 3) != MyList(4, 5, 6))
Exemple #2
0
 def test_sub_7(self):
     i = MyList(1, 2, 3)
     j = [1, 2]
     k = j - i
     self.assertEqual(k, MyList(0, 0, 3))
Exemple #3
0
 def test_sub_2(self):
     i = MyList(1, 2, 3)
     j = [4, 5, 6]
     k = i - j
     self.assertEqual(k, MyList(-3, -3, -3))
Exemple #4
0
 def test_sub_4(self):
     i = MyList(1, 2, 3)
     j = MyList(1, 2)
     k = i - j
     self.assertEqual(k, MyList(0, 0, 3))
Exemple #5
0
 def test_add_6(self):
     i = MyList(1, 2, 3)
     j = [1, 2]
     k = i + j
     self.assertEqual(k, MyList(2, 4, 3))
Exemple #6
0
 def test_eq(self):
     self.assertTrue(MyList(1, 2, 3) == MyList(3, 2, 1))
Exemple #7
0
 def test_neg(self):
     i = MyList(1, -2, 3)
     j = -i
     self.assertEqual(j, MyList(-1, 2, -3))
Exemple #8
0
 def test_add_4(self):
     i = MyList(1, 2, 3)
     j = MyList(1, 2)
     k = i + j
     self.assertEqual(k, MyList(2, 4, 3))
Exemple #9
0
 def test_imul_6(self):
     i = [1, 2]
     i *= MyList(1, 2, 3)
     self.assertEqual(i, MyList(1, 4, 3))
Exemple #10
0
 def test_abs(self):
     i = MyList(1, -2, 3)
     j = abs(i)
     self.assertEqual(j, MyList(1, 2, 3))
Exemple #11
0
 def test_imul_5(self):
     i = MyList(1, 2, 3)
     i *= [1, 2]
     self.assertEqual(i, MyList(1, 4, 3))
Exemple #12
0
 def test_imul_4(self):
     i = MyList(1, 2, 3)
     i *= MyList(1, 2)
     self.assertEqual(i, MyList(1, 4, 3))
Exemple #13
0
 def test_imul_3(self):
     i = MyList(1, 2, 3)
     i *= MyList(1, 2, 3)
     self.assertEqual(i, MyList(1, 4, 9))
Exemple #14
0
 def test_imul_2(self):
     i = MyList(1, 2, 3)
     i *= [1, 2, 3]
     self.assertEqual(i, MyList(1, 4, 9))
Exemple #15
0
 def test_append(self):
     i = MyList(1, 2)
     i.append(3)
     j = MyList(1, 2, 3)
     self.assertEqual(i, j)
Exemple #16
0
 def test_sort_3(self):
     i = MyList(8, 9, 10, 7, 6, 5, 0, 1, 2, 4, 3)
     i.sort(key=lambda x: -x)
     j = MyList(10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
     self.assertEqual(i, j)
Exemple #17
0
 def test_clear(self):
     i = MyList(1, 2, 3)
     i.clear()
     j = MyList()
     self.assertEqual(i, j)
Exemple #18
0
 def test_add_5(self):
     i = MyList(1, 2, 3)
     j = MyList(1, 2)
     k = j + i
     self.assertEqual(k, MyList(2, 4, 3))
Exemple #19
0
 def test_copy(self):
     i = MyList(1, 2, 3)
     j = i.copy()
     self.assertTrue(i is not j)
Exemple #20
0
 def test_add_7(self):
     i = MyList(1, 2, 3)
     j = [1, 2]
     k = j + i
     self.assertEqual(k, MyList(2, 4, 3))
Exemple #21
0
 def test_count(self):
     i = MyList(0, 1, 1, 2, 3, 5, 8, 13)
     self.assertEqual(i.count(0), 1)
     self.assertEqual(i.count(1), 2)
     self.assertEqual(i.count(10), 0)
Exemple #22
0
 def test_sub_1(self):
     i = MyList(1, 2, 3)
     j = 3
     k = i - j
     self.assertEqual(k, MyList(-2, -1, 0))
Exemple #23
0
 def test_index(self):
     i = MyList(0, 1, 1, 2, 3, 5, 8, 13)
     self.assertEqual(i.index(0), 0)
     self.assertEqual(i.index(1), 1)
     with self.assertRaises(ValueError):
         i.index(10)
Exemple #24
0
 def test_sub_3(self):
     i = MyList(1, 2, 3)
     j = MyList(4, 5, 6)
     k = i - j
     self.assertEqual(k, MyList(-3, -3, -3))
Exemple #25
0
 def test_remove(self):
     i = MyList(0, 1, 1, 2, 3, 5, 8, 13)
     i.remove(1)
     j = MyList(0, 1, 2, 3, 5, 8, 13)
     self.assertEqual(i, j)
Exemple #26
0
 def test_sub_5(self):
     i = MyList(1, 2, 3)
     j = MyList(1, 2)
     k = j - i
     self.assertEqual(k, MyList(0, 0, 3))
Exemple #27
0
 def test_sort_1(self):
     i = MyList(8, 9, 10, 7, 6, 5, 0, 1, 2, 4, 3)
     i.sort()
     j = MyList(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     self.assertEqual(i, j)
Exemple #28
0
 def test_sub_6(self):
     i = MyList(1, 2, 3)
     j = [1, 2]
     k = i - j
     self.assertEqual(k, MyList(0, 0, 3))
Exemple #29
0
 def test_sort_2(self):
     i = MyList(8, 9, 10, 7, 6, 5, 0, 1, 2, 4, 3)
     i.sort(reverse=True)
     j = MyList(10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
     self.assertEqual(i, j)
Exemple #30
0
 def test_insert(self):
     l = MyList()
     self.assertTrue(l.insert(1, 5))
     self.assertFalse(l.insert(0, 100))
     self.assertFalse(l.insert(100, 200))
Exemple #31
0
 def test_imul_1(self):
     i = MyList(1, 2, 3)
     i *= 3
     self.assertEqual(i, MyList(3, 6, 9))