Exemplo n.º 1
0
    def test_getIndex_whenIndexIsNotValie_RaiseException(self):
        test = IntegerList(1, 2, 3, 4, 5, 6, 7)

        with self.assertRaises(Exception) as context:
            test.get(len(test.get_data()))

        self.assertIsNotNone(context.exception)
Exemplo n.º 2
0
    def test_insertWhenIndexIsInValidShouldShouldReturnRaise(self):
        test = IntegerList(1, 2, 3, 4, 5, 6, 7)
        with self.assertRaises(Exception) as context:
            test.insert(len(test.get_data()), -1)

        self.assertIsNotNone(context.exception)
Exemplo n.º 3
0
 def test_insertWhenIndexIsValidShouldReturnIndex(self):
     test = IntegerList(1, 2, 3, 4, 5, 6, 7)
     test.insert(2, -1)
     self.assertEqual([1, 2, -1, 3, 4, 5, 6, 7], test.get_data())
Exemplo n.º 4
0
 def test_removeIndex_whenIndexIsValid_ShouldRemoveElement_andreturn(self):
     test = IntegerList(1, 2, 3, 4, 5, 6, 7)
     returned = test.remove_index(3)
     expected = 4
     self.assertEqual(returned, expected)
     self.assertListEqual([1, 2, 3, 5, 6, 7], test.get_data())
Exemplo n.º 5
0
    def test_integerListAddWhenValueisInteger_ShouldBeAdded(self):
        test = IntegerList()
        test.add(1)

        self.assertEqual([1], test.get_data())
Exemplo n.º 6
0
    def test_integerListWhenOnlyIntegerShouldStore(self):
        values = [1, 2, 3, 4, 5]
        l = IntegerList(*values)

        self.assertListEqual(values, l.get_data())