コード例 #1
0
 def test_linkedlist_functionality(self):
     input_list = [1,0,3,6,5,10]
     obj_linked_list = LinkedList(input_list[0])
     for each_ele in input_list[1:]:
         obj_linked_list.insert(each_ele)
     self.logger.info("processing linked list for rearranging")
     (list1, list2, data) = obj_linked_list.rearrange_list()
     self.assertEqual([5, 0, 6, 1, 10, 3],data)
コード例 #2
0
    def test_copy(self):

        nodes = []
        for i in range(SIZE):
            nodes.append(Node(i))

            if i:
                nodes[i - 1].next = nodes[i]

        for i in range(SIZE):
            number = randint(0, SIZE)
            if number < SIZE:
                nodes[i].random = nodes[number]

        if nodes:
            linked_list = LinkedList(nodes[0])
            linked_list_copy = linked_list.copy()

            loop = linked_list.head
            loop_copy = linked_list_copy.head

            while loop:
                self.assertEqual(loop.data, loop_copy.data)

                if loop.next:
                    self.assertEqual(loop.next.data, loop_copy.next.data)

                if loop.random:
                    self.assertEqual(loop.random.data, loop_copy.random.data)

                loop = loop.next
                loop_copy = loop_copy.next

            print('----------------------------------------')
            print('Original')
            print('----------------------------------------')
            print(linked_list)
            print('----------------------------------------')
            print('Copia')
            print('----------------------------------------')
            print(linked_list_copy)
コード例 #3
0
                                    "log", "linked_list.log")
        handler = RotatingFileHandler(log_path,
                                      maxBytes=1024 * 1024,
                                      backupCount=5)
        handler.setFormatter(myfmtr)
        logger = logging.getLogger("LinkedList")
        logger.addHandler(handler)
        return logger


if __name__ == "__main__":
    """
    This is Executor and 
    to execute navigate to 
    "..\linked_list_arranger\src" and type 
    'python main.py'
    press enter
    """

    #input_list = [0,5,2,8,1,100,101,78,40,25,12]
    input_list = [1, 0, 3, 6, 5, 10]

    logger = Logger().create_logger()
    output_file_name = "output_array.json"
    obj_linked_list = LinkedList(input_list[0])
    for each_ele in input_list[1:]:
        obj_linked_list.insert(each_ele)
    logger.info("processing linked list for rearranging")

    (list1, list2, data) = obj_linked_list.rearrange_list(output_file_name)
    logger.info(str(data))
コード例 #4
0
ファイル: main.py プロジェクト: Deeps12/linkedlist_Arranger
                                            "log",
                                            "linked_list.log")
        handler = RotatingFileHandler(log_path,
                                          maxBytes=1024*1024,
                                          backupCount=5)
        handler.setFormatter(myfmtr)
        logger = logging.getLogger("LinkedList")
        logger.addHandler(handler)
        return logger
        
if __name__ == "__main__":
    """
    This is Executor and 
    to execute navigate to 
    "..\linked_list_arranger\src" and type 
    'python main.py'
    press enter
    """
    
    #input_list = [0,5,2,8,1,100,101,78,40,25,12]
    input_list = [1,0,3,6,5,10]
    
    logger = Logger().create_logger()
    output_file_name = "output_array.json"
    obj_linked_list = LinkedList(input_list[0])
    for each_ele in input_list[1:]:
        obj_linked_list.insert(each_ele)
    logger.info("processing linked list for rearranging")
    
    (list1, list2, data) = obj_linked_list.rearrange_list(output_file_name)
    logger.info(str(data))
コード例 #5
0
 def test_empty_linked_list_creation(self):
     '''
     This wil test empty linked test can be created
     '''
     obj_linked_list = LinkedList()
     self.assertIsInstance(obj_linked_list, LinkedList)