from node import Node
from detect_cycle import detect_cycle


"""
Driver to test reverse linked list
"""
def main():
    # Case 1: 5-node list input with no cycle
    # Expected Output: Cycle not detected!
    node1 = Node(1)
    node2 = Node(2, node1)
    node3 = Node(3, node2)
    node4 = Node(4, node3)
    node5 = Node(5, node4)

    if detect_cycle(node5):
        print("Cycle detected!", end=" ")
    else:
        print("Cycle not detected!", end=" ")
    print()

    # Case 2: 5-node list input with cycle
    # Expected Output: Cycle detected!
    node1.next = node5

    if detect_cycle(node5):
        print("Cycle detected!", end=" ")
    else:
        print("Cycle not detected!", end=" ")
    print()

    # Case 3: 2-node list with cycle
    # Expected Output: Cycle detected!
    node1 = Node(1)
    node2 = Node(2, node1)
    node1.next = node2

    if detect_cycle(node2):
        print("Cycle detected!", end=" ")
    else:
        print("Cycle not detected!", end=" ")
    print()

    # Case 4: 2-node list with no cycle
    # Expected Output: Cycle not detected!
    node6 = Node(6)
    node7 = Node(7, node6)

    if detect_cycle(node7):
        print("Cycle detected!", end=" ")
    else:
        print("Cycle not detected!", end=" ")
    print()

    # Case 5: 1-node list
    # Expected Output: Cycle not detected!
    node = Node(0)
    
    if detect_cycle(node):
        print("Cycle detected!", end=" ")
    else:
        print("Cycle not detected!", end=" ")
    
    print()

if __name__ == "__main__":
   main()