コード例 #1
0
    def test_remove_when_item_is_present_and_head_item_is_removed_when_linkedlist_is_only_one_item(
            self):
        # Arrange
        linkedlist = LinkedList()
        linkedlist.push_back("Umair")

        # Act
        removed = linkedlist.remove("Umair")

        # Assert
        self.assertTrue(removed)
        self.assertRaises(ValueError, linkedlist.find, "Umair")
        self.assertTrue(linkedlist.size() == 0)
コード例 #2
0
    def test_remove_when_item_is_present_and_non_head_middle_item_is_removed_when_list_is_more_than_one_item(
            self):
        # Arrange
        linkedlist = LinkedList()
        linkedlist.push_back("Umair")
        linkedlist.push_back("Aamir")
        linkedlist.push_back("Usman")

        # Act
        removed = linkedlist.remove("Aamir")

        # Assert
        self.assertTrue(removed)
        self.assertRaises(ValueError, linkedlist.find, "Aamir")
        self.assertTrue(linkedlist.size() == 2)