PRQuadTree / src / SkipNodeTest.java
SkipNodeTest.java
Raw
import student.TestCase;

/**
 * 
 * @author nickgrifasi
 * @version 9/20/21 Tests the SkipNode class and all of its public methods
 */
public class SkipNodeTest extends TestCase {

    private SkipNode<String, String> testNode;
    private SkipNode<String, String> testNode2;
    private KVPair<String, String> testRec;
    private KVPair<String, String> testRec2;

    /**
     * setup method for SkipNodeTest
     */
    public void setUp() {
        // left empty
    }

    /**
     * test the null and base case for getter key()
     */
    public void testKey() {
        testRec = new KVPair<String, String>("test", "test1");
        testNode = new SkipNode<String, String>(testRec, 5);

        assertEquals(testRec.getKey(), testNode.getPair().getKey());

        testRec2 = new KVPair<String, String>(null, null);
        testNode2 = new SkipNode<String, String>(testRec2, 5);
        assertEquals(null, testNode2.getPair().getKey());

        assertEquals("test", testNode.key());
        assertEquals(null, testNode2.key());
        KVPair<String, String> testRec3 = new
                KVPair<String, String>(null, null);
        SkipNode<String, String> testNode3 = new
                SkipNode<String, String>(testRec3, 5);
        testRec = null;
        
        assertEquals(null, testNode3.key());
        
        
        try
        {
            testNode.getPair();
        }
        catch (Exception e) {
            //
        }
        
    }

    /**
     * test the null and base case for getter element()
     */
    public void testElement() {
        testRec = new KVPair<String, String>("test", "test1");
        testNode = new SkipNode<String, String>(testRec, 5);

        assertEquals("test1", testNode.getPair().getNodeData());

        testRec2 = new KVPair<String, String>(null, null);
        testNode2 = new SkipNode<String, String>(testRec2, 5);
        assertEquals(null, testNode2.getPair().getNodeData());
    }
    

}