skipList / src / KVPairTest.java
KVPairTest.java
Raw
import student.TestCase;

/**
 * 
 * @author nickgrifasi
 * @version 9/20/21 Tests the KVPair class
 */
public class KVPairTest extends TestCase {

    private KVPair<String, String> kvpair;

    /**
     * method to setUp test class
     */
    public void setUp() {
        //method left intentionally blank
    }

    /**
     * Tests the getKey() method
     */
    public void testGetKey() {
        kvpair = new KVPair<String, String>("test", "pair");

        assertEquals("test", kvpair.getKey());
    }

    /**
     * tests the getNodeData() method
     */
    public void testGetNodeData() {
        kvpair = new KVPair<String, String>("test", "pair");
        assertEquals("pair", kvpair.getNodeData());
    }

    /**
     * tests the compareTo() method
     */
    public void testCompareTo() {
        kvpair = new KVPair<String, String>("test", "pair");
        KVPair<String, String> kvpair2 = new 
                KVPair<String, String>("test2", "pair3");
        KVPair<String, String> kvpair3 = new 
                KVPair<String, String>("test", "pair3");

        assertEquals(0, kvpair.getKey().compareTo(kvpair3.getKey()));
        assertEquals(1, kvpair2.getKey().compareTo(kvpair3.getKey()));
        assertEquals(-1, kvpair3.getKey().compareTo(kvpair2.getKey()));
        assertEquals(0, kvpair.getKey().compareTo("test"));
        assertEquals(kvpair.compareTo(kvpair2.getKey()), -1);
        assertEquals(kvpair.getKey().compareTo("zest"), -6);
    }

}