Example #1
0
 def test_ne(self):
     self.assertTrue(MyList(1, 2, 3) != MyList(4, 5, 6))
Example #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))
Example #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))
Example #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))
Example #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))
Example #6
0
 def test_eq(self):
     self.assertTrue(MyList(1, 2, 3) == MyList(3, 2, 1))
Example #7
0
 def test_neg(self):
     i = MyList(1, -2, 3)
     j = -i
     self.assertEqual(j, MyList(-1, 2, -3))
Example #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))
Example #9
0
 def test_imul_6(self):
     i = [1, 2]
     i *= MyList(1, 2, 3)
     self.assertEqual(i, MyList(1, 4, 3))
Example #10
0
 def test_abs(self):
     i = MyList(1, -2, 3)
     j = abs(i)
     self.assertEqual(j, MyList(1, 2, 3))
Example #11
0
 def test_imul_5(self):
     i = MyList(1, 2, 3)
     i *= [1, 2]
     self.assertEqual(i, MyList(1, 4, 3))
Example #12
0
 def test_imul_4(self):
     i = MyList(1, 2, 3)
     i *= MyList(1, 2)
     self.assertEqual(i, MyList(1, 4, 3))
Example #13
0
 def test_imul_3(self):
     i = MyList(1, 2, 3)
     i *= MyList(1, 2, 3)
     self.assertEqual(i, MyList(1, 4, 9))
Example #14
0
 def test_imul_2(self):
     i = MyList(1, 2, 3)
     i *= [1, 2, 3]
     self.assertEqual(i, MyList(1, 4, 9))
Example #15
0
 def test_append(self):
     i = MyList(1, 2)
     i.append(3)
     j = MyList(1, 2, 3)
     self.assertEqual(i, j)
Example #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)
Example #17
0
 def test_clear(self):
     i = MyList(1, 2, 3)
     i.clear()
     j = MyList()
     self.assertEqual(i, j)
Example #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))
Example #19
0
 def test_copy(self):
     i = MyList(1, 2, 3)
     j = i.copy()
     self.assertTrue(i is not j)
Example #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))
Example #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)
Example #22
0
 def test_sub_1(self):
     i = MyList(1, 2, 3)
     j = 3
     k = i - j
     self.assertEqual(k, MyList(-2, -1, 0))
Example #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)
Example #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))
Example #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)
Example #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))
Example #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)
Example #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))
Example #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)
Example #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))
Example #31
0
 def test_imul_1(self):
     i = MyList(1, 2, 3)
     i *= 3
     self.assertEqual(i, MyList(3, 6, 9))