forked from ucsd-cse15l-w23/lab3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListTests.java
More file actions
46 lines (36 loc) · 1.05 KB
/
ListTests.java
File metadata and controls
46 lines (36 loc) · 1.05 KB
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
import static org.junit.Assert.*;
import org.junit.*;
import java.util.ArrayList;
public class ListTests {
@Test
public void testFilter(){
ArrayList<String> al = new ArrayList<String>();
al.add("Brandon");
al.add("Ziad");
al.add("Dhruv");
al.add("Colby");
al.add("Shashwat");
assertArrayEquals(new String[]{"Brandon","Shashwat"},ListExamples.filter(al,new LargeString()).toArray());
}
@Test
public void testMerge(){
ArrayList<String> a = new ArrayList<String>();
ArrayList<String> b = new ArrayList<String>();
b.add("a");
a.add("a");
b.add("b");
a.add("b");
b.add("b");
a.add("c");
b.add("e");
b.add("e");
b.add("e");
a.add("d");
assertArrayEquals(new String[]{"a","a","b","b","b","c","d","e","e","e"},ListExamples.merge(a,b).toArray());
}
}
class LargeString implements StringChecker{
public boolean checkString(String s){
return s.length()>5;
}
}