forked from ucsd-cse15l-f22/list-examples-grader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestListExamples.java
More file actions
42 lines (31 loc) · 926 Bytes
/
TestListExamples.java
File metadata and controls
42 lines (31 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.*;
import org.junit.*;
class LongString implements StringChecker{
public boolean checkString(String s){
if (s.length() > 5){
return true;
}
else{
return false;
}
}
}
public class TestListExamples {
// Write your grading tests here!
@Test
public void testFilter(){
List<String> input = Arrays.asList("apple", "banana", "pear", "strawberry", "blackberry");
StringChecker sc = new LongString();
List<String> expected = Arrays.asList("banana", "strawberry", "blackberry");
assertEquals(expected, ListExamples.filter(input, sc));
}
@Test
public void testMerge(){
List<String> input1 = Arrays.asList("a","h","k");
List<String> input2 = Arrays.asList("b", "n");
List<String> expected = Arrays.asList("a", "b", "h", "k", "n");
assertEquals(expected, ListExamples.merge(input1, input2));
}
}