forked from ucsd-cse15l-f23/lab3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ListTests.java
47 lines (41 loc) · 1.29 KB
/
ListTests.java
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
42
43
44
45
46
47
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import org.junit.*;
class StringChecker2 implements StringChecker {
public boolean checkString(String s) {
if (s.charAt(0) == 's') {
return true;
}
return false;
}
}
public class ListTests {
@Test
public void testFilter() {
List<String> stringList = new ArrayList<String>();
stringList.add("string");
stringList.add("ey");
stringList.add("s2");
List<String> stringList2 = new ArrayList<String>();
stringList2.add("string");
stringList2.add("s2");
StringChecker2 sc = new StringChecker2();
assertEquals(stringList2, ListExamples.filter(stringList, sc));
}
@Test
public void testMerge() {
List<String> stringList = new ArrayList<String>();
stringList.add("a");
stringList.add("b");
List<String> stringList2 = new ArrayList<String>();
stringList2.add("a");
stringList2.add("d");
List<String> stringList3 = new ArrayList<String>();
stringList3.add("a");
stringList3.add("a");
stringList3.add("b");
stringList3.add("d");
assertEquals(stringList3, ListExamples.merge(stringList, stringList2));
}
}