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
47 lines (32 loc) · 1.01 KB
/
ListTests.java
File metadata and controls
47 lines (32 loc) · 1.01 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
47
import static org.junit.Assert.*;
import org.junit.*;
import java.util.ArrayList;
public class ListTests {
public StringChecker sc;
@Before
public void setUp() throws Exception {
sc = new ListExamples();
}
@Test
public void testFilter(){
ArrayList<String> list = new ArrayList<>();
list.add("hi");
list.add("um");
list.add("boo");
list.add("hate");
list.add("boo");
String[] expected = {"hi", "boo", "boo"};
assertArrayEquals(expected, ListExamples.filter(list, sc).toArray());
}
@Test
public void testMerge(){
ArrayList<String> list1 = new ArrayList<>();
ArrayList<String> list2 = new ArrayList<>();
list1.add("book");
list1.add("dog");
list2.add("apple");
list2.add("hello");
list1.add("evening");
assertArrayEquals(new String[]{"apple", "book", "dog", "evening", "hello"}, ListExamples.merge(list1, list2).toArray());
}
}