コード例 #1
0
    def test_size_when_more_than_one_element_in_myarray(self):
        # Arrange
        myarray = MyArray('i', 100, 200)

        # Act
        size = myarray.size()

        # Assert
        self.assertEqual(2, size)
コード例 #2
0
    def test_size_when_empty_myarray(self):
        # Arrange
        myarray = MyArray()

        # Act
        size = myarray.size()

        # Assert
        self.assertEqual(0, size)
コード例 #3
0
    def test_pop_when_single_element_in_myarray(self):
        # Arrange
        myarray = MyArray('i', 20)

        # Act
        myarray.pop()

        # Assert
        self.assertEqual(0, myarray.size())
コード例 #4
0
    def test_size_when_single_element_in_myarray(self):
        # Arrange
        myarray = MyArray('i', 100)

        # Act
        size = myarray.size()

        # Assert
        self.assertEqual(1, size)
コード例 #5
0
    def test_append_when_empty_myarray(self):
        # Arrange
        myarray = MyArray('i')

        # Act
        myarray.append(100)

        # Assert
        self.assertEqual(1, myarray.size())
        self.assertEqual(100, myarray.get(0))
コード例 #6
0
    def test_insert_when_more_than_one_element_in_myarray(self):
        # Arrange
        myarray = MyArray('i', 1, 2, 3, 4, 5)

        # Act
        myarray.insert(2, 99)

        # Assert
        self.assertEqual(6, myarray.size())  # (expected, actual)
        self.assertEqual(99, myarray.get(2))
コード例 #7
0
    def test_insert_when_single_item_myarray(self):
        # Arrange
        myarray = MyArray('i', 1)

        # Act
        myarray.insert(0, 99)

        # Assert
        self.assertEqual(2, myarray.size())  # (expected, actual)
        self.assertEqual(99, myarray.get(0))
コード例 #8
0
    def test_insert_when_empty_myarray(self):
        # Arrange
        myarray = MyArray('i')

        # Act
        myarray.insert(0, 99)

        # Assert
        self.assertEqual(1, myarray.size())
        self.assertEqual(99, myarray.get(0))
コード例 #9
0
    def test_pop_when_more_than_one_element_in_myarray(self):
        # Arrange
        myarray = MyArray('i', 20, 30)

        # Act
        myarray.pop(0)

        # Assert
        self.assertEqual(1, myarray.size())
        self.assertEqual(30, myarray.get(0))
コード例 #10
0
    def test_append_when_single_element_in_myarray(self):
        # Arrange
        myarray = MyArray('i', 100)

        # Act
        myarray.append(200)

        # Assert
        self.assertEqual(2, myarray.size())
        self.assertEqual(100, myarray.get(0))
        self.assertEqual(200, myarray.get(1))
コード例 #11
0
    def test_pop_when_more_than_two_element_in_myarray(self):
        # Arrange
        myarray = MyArray('i', 20, 30, 40)

        # Act
        myarray.pop(1)

        # Assert
        self.assertEqual(2, myarray.size())
        self.assertEqual(20, myarray.get(0))
        self.assertEqual(40, myarray.get(1))
コード例 #12
0
    def test_append_when_more_than_one_element_in_myarray(self):
        # Arrange
        myarray = MyArray('i', 100, 200)

        # Act
        myarray.append(300)

        # Assert
        self.assertEqual(3, myarray.size())
        self.assertEqual(100, myarray.get(0))
        self.assertEqual(200, myarray.get(1))
        self.assertEqual(300, myarray.get(2))