~cpp
import java.util.Vector;
import junit.framework.TestCase;
public class JollyJumperTest extends TestCase {
public void testJollyJumper() {
Vector vec = new Vector();
vec.add(new Integer(1));
JollyJumper jollyJumper = new JollyJumper();
assertEquals(true, jollyJumper.isJollyJumper(vec));
}
public void testGetGap() {
Vector vec = new Vector();
vec.add(new Integer(1));
vec.add(new Integer(4));
vec.add(new Integer(10));
JollyJumper jollyJumper = new JollyJumper();
assertEquals(3, jollyJumper.getGap(vec, 0));
assertEquals(6, jollyJumper.getGap(vec, 1));
}
public void testJollyJumperTwo() {
Vector vec = new Vector();
vec.add(new Integer(5));
vec.add(new Integer(1));
vec.add(new Integer(4));
vec.add(new Integer(2));
vec.add(new Integer(3));
JollyJumper jollyJumper = new JollyJumper();
assertEquals(true, jollyJumper.isJollyJumper(vec));
}
public void testJollyJumperThree() {
Vector vec = new Vector();
vec.add(new Integer(5));
vec.add(new Integer(1));
vec.add(new Integer(4));
vec.add(new Integer(2));
vec.add(new Integer(-1));
vec.add(new Integer(6));
JollyJumper jollyJumper = new JollyJumper();
assertEquals(false, jollyJumper.isJollyJumper(vec));
}
}
이번엔 TDD로... 쉬운 알고리즘이라 테스트를 몇 개 안만들고 끝냈다. --재동