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