下面是代码的图片,也在页面底部的超链接“junit”中。我目前有两个测试,编码为“method:insert”,您可以在左侧看到。我需要的主要代码去绿色,也得到100%的覆盖面,我目前在78%。我需要添加什么才能通过junit?朱尼特
This is my JUNIT test code:
@Test
public void testInsert() {
SortedIntegerList list = new SortedIntegerList();
list.insert(1);
list.insert(2);
Integer output = list.getLast();
assertNotNull(output);
SortedIntegerList list2 = new SortedIntegerList();
list2.insert(1);
list2.insert(2);
Integer data = 0;
assertNotNull(data);
}
@Test
public void testInsertif() {
SortedIntegerList list = new SortedIntegerList();
list.insert(1);
Integer result = list.getLast();
assertNotNull(result);
}
@Test
public void testInsertwhile() {
SortedIntegerList list = new SortedIntegerList();
list.insert(1);
}
This is the insert Code:
public void insert(Integer data) {
Node curr, foll;
if ((first == null) || (data <= first.data)) {
first = new Node(data, first);
} else {
curr = first;
foll = first.next;
while ((foll != null) && (foll.data < data)) {
curr = foll;
foll = foll.next;
}
curr.next = new Node(data, foll);
}
}
暂无答案!
目前还没有任何答案,快来回答吧!