Пример #1
0
class TestInsertIntoSortedList(unittest.TestCase):
    def setUp(self):
        self.linked_list = SingleLinkedList()

    def create_list(self):
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(1)
        self.linked_list.insert_at_end(2)
        self.linked_list.insert_at_end(6)
        self.linked_list.insert_at_end(8)
        self.linked_list.insert_at_end(12)
        # 1 --> 2 --> 6 --> 8 --> 12

    def test_insert_into_sorted_list(self):
        print("TEST INSERT INTO A SORTED LIST")
        print("===========================================================")

        print("List: <Empty list>")
        try:
            print("<", end="")
            insert_into_sorted_list(self.linked_list, 32)
        except EmptyListError as e:
            print(str(e), end=">\n\n")

        self.create_list()
        print("List: " + self.linked_list.get_list())

        insert_into_sorted_list(self.linked_list, -1)
        self.assertEqual(self.linked_list.get_list(),
                         "-1 \u27F6 1 \u27F6 2 \u27F6 6 \u27F6 8 \u27F6 12")
        print("List after inserting -1: ", self.linked_list.get_list())

        insert_into_sorted_list(self.linked_list, 5)
        self.assertEqual(
            self.linked_list.get_list(),
            "-1 \u27F6 1 \u27F6 2 \u27F6 5 \u27F6 6 \u27F6 8 \u27F6 12")
        print("List after inserting 5: ", self.linked_list.get_list())

        insert_into_sorted_list(self.linked_list, 20)
        self.assertEqual(
            self.linked_list.get_list(),
            "-1 \u27F6 1 \u27F6 2 \u27F6 5 \u27F6 6 \u27F6 8 \u27F6 12 \u27F6 20"
        )
        print("List after inserting 20: ", self.linked_list.get_list())

        insert_into_sorted_list(self.linked_list, 8)
        self.assertEqual(
            self.linked_list.get_list(),
            "-1 \u27F6 1 \u27F6 2 \u27F6 5 \u27F6 6 \u27F6 8 \u27F6 8 \u27F6 12 \u27F6 20"
        )
        print("List after inserting 8: ", self.linked_list.get_list())

        print(
            ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")
Пример #2
0
class TestFloydCycleFindingAlgorithm(unittest.TestCase):
    def setUp(self):
        self.linked_list = SingleLinkedList()

    def create_list(self):
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(5)
        self.linked_list.insert_at_end(1)
        self.linked_list.insert_at_end(23)
        self.linked_list.insert_at_end(27)
        self.linked_list.insert_at_end(99)
        self.linked_list.insert_at_end(32)
        self.linked_list.insert_at_end(61)
        self.linked_list.insert_at_end(33)
        self.linked_list.insert_at_end(87)
        self.linked_list.insert_at_end(47)
        self.linked_list.insert_at_end(43)
        # 5 --> 1 --> 23 --> 27 --> 99 --> 32 --> 61 --> 33 --> 87 --> 47 --> 43

    def test_loop_in_a_list(self):
        print("TEST LOOP IN A LIST - FLOYD CYCLE FINDING ALGORITHM")
        print("===========================================================")

        print("List: <Empty list>")
        try:
            print("<", end="")
            loop_in_a_list(self.linked_list)
        except EmptyListError as e:
            print(str(e), end=">\n\n")

        # ======================
        # Test with a list.
        # ======================
        self.create_list()
        print("List: " + self.linked_list.get_list())

        is_cyclic, data = loop_in_a_list(self.linked_list)
        self.assertEqual(is_cyclic, False)
        print("Loop does not exist.", end="\n\n")

        # Create loop at 4th node in the list.
        pointer = self.linked_list.head
        position = 1
        while position != 4:
            pointer = pointer.get_next()
            position += 1

        loop_start_node = pointer
        while pointer.get_next():
            pointer = pointer.get_next()

        pointer.set_next(loop_start_node)

        print("List:")
        print(" " * 20 + "\u2197 99 \u27F6 32 \u27F6 61 \u2198")
        print("5 \u27F6 1 \u27F6 23 \u27F6 27" + " " * 20 + "33")
        print(" " * 20 + "\u2196 43 \u27F5 47 \u27F5 87 \u2199")

        is_cyclic, data = loop_in_a_list(self.linked_list)
        self.assertEqual(is_cyclic, True)
        self.assertEqual(data, 27)
        print("\nLoop exists with start node at {0}.".format(27))

        loop_length = lenth_of_the_loop(self.linked_list)
        self.assertEqual(loop_length, 8)
        print("Length of the loop = {0}.\n\n".format(loop_length))

        # ======================
        # Test with another list.
        # ======================
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(5)
        self.linked_list.insert_at_end(1)
        self.linked_list.insert_at_end(23)
        self.linked_list.insert_at_end(48)

        # Create loop at 3rd node in the list.
        pointer = self.linked_list.head
        position = 1
        while position != 3:
            pointer = pointer.get_next()
            position += 1

        loop_start_node = pointer
        while pointer.get_next():
            pointer = pointer.get_next()

        pointer.set_next(loop_start_node)

        print("List:")
        print("5 \u27F6 1 \u27F6 23 \u2500\u2500\u2510")
        print("           \u2191    \u2193")
        print("           \u2514\u2500\u2500 48")

        is_cyclic, data = loop_in_a_list(self.linked_list)
        self.assertEqual(is_cyclic, True)
        self.assertEqual(data, 23)
        print("\nLoop exists with start node at {0}.".format(27))

        loop_length = lenth_of_the_loop(self.linked_list)
        self.assertEqual(loop_length, 2)
        print("Length of the loop = {0}.".format(loop_length))

        print(
            ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")
class TestNthNodeFromEnd(unittest.TestCase):
    def setUp(self):
        self.linked_list = SingleLinkedList()

    def create_list(self):
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(5)
        self.linked_list.insert_at_end(10)
        self.linked_list.insert_at_end(2)
        self.linked_list.insert_at_end(27)
        self.linked_list.insert_at_end(99)
        # 5 --> 10 --> 2 --> 27 --> 99

    def test_nth_from_end_two_scans(self):
        print("TEST NTH NODE FROM END - TWO SCANS")
        print("===========================================================")

        print("List: <Empty list>")
        try:
            print("n = 1, Node = Not found <", end="")
            print(nth_node_from_end(self.linked_list, 1))
        except EmptyListError as e:
            print(str(e), end=">\n\n")

        self.linked_list.insert_at_beginning(22)
        print("List: " + self.linked_list.get_list())
        try:
            print("n = 4, Node = Not found <", end="")
            nth_node_from_end(self.linked_list, 4)
        except RangeError as e:
            print(str(e), end=">\n\n")

        self.create_list()
        print("List: " + self.linked_list.get_list())

        n = nth_node_from_end(self.linked_list, 2)
        self.assertEqual(n, 27)
        print("n = 2, Node =", n)

        n = nth_node_from_end(self.linked_list, 5)
        self.assertEqual(n, 5)
        print("n = 5, Node =", n)

        n = nth_node_from_end(self.linked_list, 1)
        self.assertEqual(n, 99)
        print("n = 1, Node =", n)

        try:
            print("n = 0, Node = Not found <", end="")
            nth_node_from_end(self.linked_list, 0)
        except RangeError as e:
            print(str(e), end=">\n")

        try:
            print("n = 6, Node = Not found <", end="")
            nth_node_from_end(self.linked_list, 6)
        except RangeError as e:
            print(str(e), end=">\n")

        print(
            ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")

    def test_nth_from_end_one_scan(self):
        print("TEST NTH NODE FROM END - ONE SCAN")
        print("===========================================================")

        print("List: <Empty list>")
        try:
            print("n = 1, Node = Not found <", end="")
            print(nth_node_from_end_single_scan(self.linked_list, 1))
        except EmptyListError as e:
            print(str(e), end=">\n\n")

        self.linked_list.insert_at_beginning(22)
        print("List: " + self.linked_list.get_list())
        try:
            print("n = 4, Node = Not found <", end="")
            nth_node_from_end_single_scan(self.linked_list, 4)
        except RangeError as e:
            print(str(e), end=">\n\n")

        self.create_list()
        print("List: " + self.linked_list.get_list())

        n = nth_node_from_end_single_scan(self.linked_list, 2)
        self.assertEqual(n, 27)
        print("n = 2, Node =", n)

        n = nth_node_from_end_single_scan(self.linked_list, 5)
        self.assertEqual(n, 5)
        print("n = 5, Node =", n)

        n = nth_node_from_end_single_scan(self.linked_list, 1)
        self.assertEqual(n, 99)
        print("n = 1, Node =", n)

        try:
            print("n = 0, Node = Not found <", end="")
            nth_node_from_end_single_scan(self.linked_list, 0)
        except RangeError as e:
            print(str(e), end=">\n")

        try:
            print("n = 6, Node = Not found <", end="")
            nth_node_from_end_single_scan(self.linked_list, 6)
        except RangeError as e:
            print(str(e), end=">\n")

        print(
            ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")
class TestFindIntersectingNode(unittest.TestCase):
    def setUp(self):
        self.linked_list = SingleLinkedList()

    def create_list(self):
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(5)
        self.linked_list.insert_at_end(81)
        self.linked_list.insert_at_end(23)
        self.linked_list.insert_at_end(8)
        self.linked_list.insert_at_end(99)
        # 5 --> 81 --> 23 --> 8 --> 99

    def test_find_intersecting_node(self):
        print("TEST INTERSECTION BETWEEN TWO LISTS")
        print("===========================================================")

        # Case 1
        print("Lists: <Empty list>")
        try:
            intersecting_node(None, None)
        except EmptyListError as e:
            print("<" + str(e) + ">", end="\n\n")

        # Case 2
        self.create_list()
        print("Lists: \n" + self.linked_list.get_list())
        try:
            intersecting_node(self.linked_list, None)
        except EmptyListError as e:
            print("<" + str(e) + ">", end="\n\n")

        # Case 3
        self.create_list()
        position = 1
        pointer = self.linked_list.head
        while position != 3:
            pointer = pointer.get_next()
            position += 1

        self.linked_list2 = SingleLinkedList()
        self.linked_list2.insert_at_end(43)
        self.linked_list2.insert_at_end(7)
        self.linked_list2.insert_at_end(87)
        self.linked_list2.insert_at_end(56)

        # Set intersecting node
        pointer2 = self.linked_list2.head
        while pointer2.get_next():
            pointer2 = pointer2.get_next()
        pointer2.set_next(pointer)

        print("Lists: ")
        print(" " * 13 + self.linked_list.get_list()[:6] + " \u2198 ")
        print(" " * 22 + self.linked_list.get_list()[8:])
        print(self.linked_list2.get_list()[:16] + " \u2197 ")

        node = intersecting_node(self.linked_list, self.linked_list2)
        self.assertEqual(node, 23)
        print("\nIntersecting node: " + str(node), end="\n\n")

        # Case 4
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(89)
        self.linked_list.insert_at_end(54)
        position = 1
        pointer = self.linked_list.head
        while position != 2:
            pointer = pointer.get_next()
            position += 1

        self.linked_list2 = SingleLinkedList()
        self.linked_list2.insert_at_end(43)

        # Set intersecting node
        pointer2 = self.linked_list2.head
        while pointer2.get_next():
            pointer2 = pointer2.get_next()
        pointer2.set_next(pointer)

        print("Lists: ")
        print(self.linked_list.get_list()[:2] + " \u2198 ")
        print(" " * 3 + self.linked_list.get_list()[4:])
        print(self.linked_list2.get_list()[:2] + " \u2197 ")

        node = intersecting_node(self.linked_list, self.linked_list2)
        self.assertEqual(node, 54)
        print("\nIntersecting node: " + str(node))

        # Case 5
        self.create_list()
        self.linked_list.insert_at_end(33)
        self.linked_list.insert_at_end(16)
        self.linked_list.insert_at_end(2)
        position = 1
        pointer = self.linked_list.head
        while position != 5:
            pointer = pointer.get_next()
            position += 1

        self.linked_list2 = SingleLinkedList()
        self.linked_list2.insert_at_end(43)
        self.linked_list2.insert_at_end(3)

        # Set intersecting node
        pointer2 = self.linked_list2.head
        while pointer2.get_next():
            pointer2 = pointer2.get_next()
        pointer2.set_next(pointer)

        print("Lists: ")
        print(self.linked_list.get_list()[:15] + " \u2198 ")
        print(" " * 22 + self.linked_list.get_list()[18:])
        print(" " * 13 + self.linked_list2.get_list()[:6] + " \u2197 ")

        node = intersecting_node(self.linked_list, self.linked_list2)
        self.assertEqual(node, 99)
        print("\nIntersecting node: " + str(node))

        print(
            ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")
class TestMiddleOfTheList(unittest.TestCase):
    def setUp(self):
        self.linked_list = SingleLinkedList()

    def create_list(self):
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(5)
        self.linked_list.insert_at_end(81)
        self.linked_list.insert_at_end(23)
        self.linked_list.insert_at_end(8)
        self.linked_list.insert_at_end(99)
        # 5 --> 81 --> 23 --> 8 --> 99

    def test_find_middle_of_the_list(self):
        print("TEST MIDDLE OF THE LIST")
        print("===========================================================")

        # Case 1
        print("Lists: <Empty list>")
        try:
            find_middle_of_the_list(self.linked_list)
        except EmptyListError as e:
            print("<" + str(e) + ">", end="\n\n")

        # Case 2
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(89)

        print("List: " + self.linked_list.get_list())
        middle_node = find_middle_of_the_list(self.linked_list)
        self.assertEqual(middle_node, 89)
        print("Middle node: " + str(middle_node), end="\n\n")

        # Case 3
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(34)
        self.linked_list.insert_at_end(62)

        print("List: " + self.linked_list.get_list())
        middle_node = find_middle_of_the_list(self.linked_list)
        self.assertEqual(middle_node, 34)
        print("Middle node: " + str(middle_node), end="\n\n")

        # Case 4
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(2)
        self.linked_list.insert_at_end(95)
        self.linked_list.insert_at_end(78)
        self.linked_list.insert_at_end(37)

        print("List: " + self.linked_list.get_list())
        middle_node = find_middle_of_the_list(self.linked_list)
        self.assertEqual(middle_node, 95)
        print("Middle node: " + str(middle_node), end="\n\n")

        # Case 5
        self.create_list()
        print("List: " + self.linked_list.get_list())

        middle_node = find_middle_of_the_list(self.linked_list)
        self.assertEqual(middle_node, 23)
        print("Middle node: " + str(middle_node), end="\n\n")

        print(
            ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")
class TestReverseSingleLinkedList(unittest.TestCase):
    def setUp(self):
        self.linked_list = SingleLinkedList()

    def create_list(self):
        self.linked_list = SingleLinkedList()
        self.linked_list.insert_at_end(5)
        self.linked_list.insert_at_end(81)
        self.linked_list.insert_at_end(23)
        self.linked_list.insert_at_end(8)
        self.linked_list.insert_at_end(99)
        self.linked_list.insert_at_end(33)
        self.linked_list.insert_at_end(67)
        # 5 --> 81 --> 23 --> 8 --> 99 --> 33 --> 67

    def test_reverse_single_linked_list(self):
        print("TEST REVERSE SINGLE LINKED LIST")
        print("===========================================================")

        print("List: <Empty list>")
        try:
            print("<", end="")
            reverse_single_linked_list(self.linked_list)
        except EmptyListError as e:
            print(str(e), end=">\n\n")

        self.linked_list.insert_at_beginning(22)
        print("List: " + self.linked_list.get_list())
        reverse_single_linked_list(self.linked_list)
        self.assertEqual(self.linked_list.get_list(), "22")
        print("Reversed list: " + self.linked_list.get_list(), end="\n\n")

        self.linked_list.insert_at_end(53)
        print("List: " + self.linked_list.get_list())
        reverse_single_linked_list(self.linked_list)
        self.assertEqual(self.linked_list.get_list(), "53 \u27F6 22")
        print("Reversed list: " + self.linked_list.get_list(), end="\n\n")

        self.create_list()
        print("List: " + self.linked_list.get_list())
        reverse_single_linked_list(self.linked_list)
        self.assertEqual(
            self.linked_list.get_list(),
            "67 \u27F6 33 \u27F6 99 \u27F6 8 \u27F6 23 \u27F6 81 \u27F6 5")
        print("Reversed list: " + self.linked_list.get_list())

        print(
            ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")
class TestSingleLinkedList(unittest.TestCase):
    def setUp(self):
        self.single = SingleLinkedList()

    def create_list(self):
        self.single = SingleLinkedList()
        self.single.insert_at_end(5)
        self.single.insert_at_end(10)
        self.single.insert_at_end(2)
        self.single.insert_at_end(27)
        self.single.insert_at_end(99)
        # 5 --> 10 --> 2 --> 27 --> 99

    def test_insert_at_beginning(self):
        print("TEST INSERT AT BEGINNING - SINGLE LINKED LIST")
        print("===========================================================")

        print("List to operate: <Empty list>")
        self.single.insert_at_beginning(22)
        self.assertEqual(self.single.get_list(), "22")
        print("After inserting 22 in the beginning: " + self.single.get_list())
        self.single.insert_at_beginning(39)
        self.assertEqual(self.single.get_list(), "39 \u27F6 22")
        print("After inserting 39 in the beginning: " + self.single.get_list() + "\n")

        self.create_list()
        print("List to operate: " + self.single.get_list())
        self.single.insert_at_beginning(24)
        self.assertEqual(
            self.single.get_list(),
            "24 \u27F6 5 \u27F6 10 \u27F6 2 \u27F6 27 \u27F6 99")
        print("After inserting 24 in the beginning: " + self.single.get_list())

        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")

    def test_insert_at_end(self):
        print("TEST INSERT AT END - SINGLE LINKED LIST")
        print("===========================================================")

        print("List to operate: <Empty list>" + self.single.get_list())
        self.single.insert_at_end(38)
        self.assertEqual(self.single.get_list(), "38")
        print("After inserting 38 at the end: " + self.single.get_list())

        self.single.insert_at_end(92)
        self.assertEqual(self.single.get_list(), "38 \u27F6 92")
        print("After inserting 92 at the end: " + self.single.get_list())

        self.single.insert_at_end(3)
        self.assertEqual(self.single.get_list(), "38 \u27F6 92 \u27F6 3")
        print("After inserting 3 at the end: " + self.single.get_list())

        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")

    def test_insert_at_position(self):
        print("TEST INSERT AT POSITION - SINGLE LINKED LIST")
        print("===========================================================")

        print("List to operate: <Empty list>" + self.single.get_list())
        try:
            self.single.insert_at_position(1, 23)
        except EmptyListError as e:
            print(str(e) + "\n")

        self.create_list()
        print("List to operate: " + self.single.get_list())
        self.single.insert_at_position(1, 92)
        self.assertEqual(
            self.single.get_list(),
            "92 \u27F6 5 \u27F6 10 \u27F6 2 \u27F6 27 \u27F6 99")
        print("After inserting 92 at position 1: " + self.single.get_list())

        self.single.insert_at_position(3, 34)
        self.assertEqual(
            self.single.get_list(),
            "92 \u27F6 5 \u27F6 34 \u27F6 10 \u27F6 2 \u27F6 27 \u27F6 99")
        print("After inserting 34 at position 3: : " + self.single.get_list())

        self.single.insert_at_position(self.single.get_length(), 61)
        self.assertEqual(
            self.single.get_list(),
            "92 \u27F6 5 \u27F6 34 \u27F6 10 \u27F6 2 \u27F6 27 \u27F6 61 \u27F6 99")
        print("After inserting 61 at position {0}: {1} ".format(
            self.single.get_length() - 1, self.single.get_list()))

        self.single.insert_at_position(self.single.get_length() + 1, 44)
        self.assertEqual(
            self.single.get_list(),
            "92 \u27F6 5 \u27F6 34 \u27F6 10 \u27F6 2 \u27F6 27 \u27F6 61 \u27F6 99 \u27F6 44")
        print("After inserting 44 at position {0}: {1} ".format(
            self.single.get_length() - 1, self.single.get_list()))

        try:
            self.single.insert_at_position(0, 93)
        except RangeError as e:
            print("Can't insert at position 0. " + str(e))

        try:
            self.single.insert_at_position(self.single.get_length() + 2, 61)
        except RangeError as e:
            print("Can't insert at position {0}. {1}".format(
                self.single.get_length() + 2, str(e)))

        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")

    def test_delete_at_beginning(self):
        print("TEST DELETE AT BEGINNING - SINGLE LINKED LIST")
        print("===========================================================")

        print("List to operate: <Empty list>" + self.single.get_list())
        try:
            self.single.delete_at_beginning()
        except EmptyListError as e:
            print(str(e) + "\n")

        self.single.insert_at_beginning(5)
        print("List to operate: " + self.single.get_list())
        self.single.delete_at_beginning()
        self.assertEqual(self.single.get_list(), "")
        print("After deleting a node in the beginning: <Empty list>\n")

        self.create_list()
        print("List to operate: " + self.single.get_list())
        self.single.delete_at_beginning()
        self.assertEqual(
            self.single.get_list(),
            "10 \u27F6 2 \u27F6 27 \u27F6 99")
        print("After deleting a node in the beginning: " + self.single.get_list())

        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")

    def test_delete_at_end(self):
        print("TEST DELETE AT END - SINGLE LINKED LIST")
        print("===========================================================")

        print("List to operate: <Empty list>" + self.single.get_list())
        try:
            self.single.delete_at_end()
        except EmptyListError as e:
            print(str(e) + "\n")

        self.single.insert_at_beginning(5)
        print("List to operate: " + self.single.get_list())
        self.single.delete_at_end()
        self.assertEqual(self.single.get_list(), "")
        print("After deleting a node at the end: <Empty list>\n")

        self.create_list()
        print("List to operate: " + self.single.get_list())
        self.single.delete_at_end()
        self.assertEqual(
            self.single.get_list(),
            "5 \u27F6 10 \u27F6 2 \u27F6 27")
        print("After deleting a node at the end: " + self.single.get_list())

        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")

    def test_delete_at_position(self):
        print("TEST DELETE AT POSITION - SINGLE LINKED LIST")
        print("===========================================================")

        print("List to operate: <Empty list>" + self.single.get_list())
        try:
            self.single.delete_at_position(1)
        except EmptyListError as e:
            print(str(e) + "\n")

        self.single.insert_at_beginning(5)
        print("List to operate: " + self.single.get_list())
        self.single.delete_at_position(1)
        self.assertEqual(self.single.get_list(), "")
        print("After deleting a node at position 1: <Empty list>\n")

        self.create_list()
        print("List to operate: " + self.single.get_list())
        self.single.delete_at_position(3)
        self.assertEqual(
            self.single.get_list(),
            "5 \u27F6 10 \u27F6 27 \u27F6 99")
        print("After deleting a node at position 3: " + self.single.get_list())

        self.single.delete_at_position(4)
        self.assertEqual(
            self.single.get_list(),
            "5 \u27F6 10 \u27F6 27")
        print("After deleting a node at position 4: " + self.single.get_list())

        try:
            self.single.delete_at_position(0)
        except RangeError as e:
            print("Can't delete at position 0. " + str(e))

        try:
            self.single.delete_at_position(self.single.get_length() + 1)
        except RangeError as e:
            print("Can't delete at position {0}. {1}".format(
                self.single.get_length() + 1, str(e)))

        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n")