validation/qbugs/REVERSE_LINKED_LIST/src/test/java/REVERSE_LINKED_LIST_Test.java
<reponame>pkuzqh/ICSE23Repair<filename>validation/qbugs/REVERSE_LINKED_LIST/src/test/java/REVERSE_LINKED_LIST_Test.javapackage java_programs;

import static org.junit.Assert.assertEquals;

import java_programs.Node;
import java_programs.REVERSE_LINKED_LIST;

public class REVERSE_LINKED_LIST_Test {

	 // Case 1: 5-node list input
    // Expected Good Output: Reversed!  1 2 3 4 5
	@org.junit.Test(timeout = 60000)
	public void test1() {
    Node node1 = new Node("1");
    Node node2 = new Node("2", node1);
    Node node3 = new Node("3", node2);
    Node node4 = new Node("4", node3);
    Node node5 = new Node("5", node4);


    Node result = REVERSE_LINKED_LIST.reverse_linked_list(node5);

    if (result.getValue() == node1.getValue()) {
        System.out.printf("Reversed! ");
    } else {
        System.out.printf("Not Reversed! ");
    }
    String actualResult = "";
    while (result != null) {
    		actualResult+=result.getValue();
        System.out.printf("%s ", result.getValue());
        result = result.getSuccessor();
    }
    	   assertEquals("12345",actualResult);
	}

    // Case 2: 1-node list input
    // Expected Output: Reversed!  0
	@org.junit.Test(timeout = 60000)
	public void test2() {
    Node node = new Node("0");
    Node result = REVERSE_LINKED_LIST.reverse_linked_list(node);

    if (result.getValue() == node.getValue()) {
        System.out.printf("Reversed! ");
    } else {
        System.out.printf("Not Reversed! ");
    }
    String actualResult = "";
    while (result != null) {
    		actualResult+=result.getValue();
        System.out.printf("%s ", result.getValue());
        result = result.getSuccessor();
    }

    assertEquals("0",actualResult);
	}

    // Case 3: None input
    // Expected Output: None
	@org.junit.Test(timeout = 60000)
	public void test3() {
	
	Node result = REVERSE_LINKED_LIST.reverse_linked_list(null);

    if (result == null) {
        System.out.printf("Reversed! ");
    } else {
        System.out.printf("Not Reversed! ");
    }
    String actualResult = "";
    while (result != null) {
        System.out.printf("%s ", result.getValue());
        result = result.getSuccessor();
    }
    
    assertEquals("",actualResult);
	}

}
