テストプログラム
NodeTest
package tdu;
import static org.junit.Assert.*;
import org.junit.Test;
import java.util.List;
import java.util.ArrayList;
public class NodeTest {
@Test
public void constructorTest0(){
Node<String> n1 = new Node<String>();
assertNull(n1.get());
assertNull(n1.next);
}
@Test
public void constructorTest1(){
Node<String> n1 = new Node<String>("abc");
assertEquals("abc", n1.get());
assertNull(n1.next);
}
@Test
public void constructorTest2(){
Node<Integer> n1 = new Node<Integer>(1);
assertEquals(new Integer(1), n1.get());
assertNull(n1.next);
}
@Test
public void setTest1(){
Node<String> n1 = new Node<String>();
n1.set("abc");
assertEquals("abc", n1.get());
assertNull(n1.next);
}
@Test
public void setTest2(){
Node<Integer> n1= new Node<Integer>();
n1.set(1);
assertEquals(new Integer(1), n1.get());
assertNull(n1.next);
}
@Test
public void toStringTest(){
Node<String> n3 = new Node<String>("def");
assertEquals("def", n3.toString());
Node<Integer> n4 = new Node<Integer>(2);
assertEquals("2", n4.toString());
List<Double> o5 = new ArrayList<Double>();
o5.add(1.23);
o5.add(4.56);
o5.add(7.89);
Node<List<Double>> n5 = new Node<List<Double>>(o5);
assertEquals("[1.23, 4.56, 7.89]",n5.toString());
}
}