forked from ucsd-cse15l-f22/lab3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileExampleTests.java
More file actions
43 lines (34 loc) · 1.42 KB
/
FileExampleTests.java
File metadata and controls
43 lines (34 loc) · 1.42 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
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertArrayEquals;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class FileExampleTests {
@Test
public void testGetFiles1() throws IOException{
File file1 = new File("some-files/more-files");
List<File> expected = new ArrayList<>();
expected.add(new File("some-files/more-files/c.java"));
expected.add(new File("some-files/more-files/b.txt"));
assertArrayEquals(expected.toArray(), FileExample.getFiles(file1).toArray());
}
@Test
public void testGetFiles2() throws IOException{
List<File> expected = new ArrayList<>();
File file2 = new File("some-files/");
expected.add(new File("some-files/even-more-files/d.java"));
expected.add(new File("some-files/even-more-files/a.txt"));
expected.add(new File("some-files/more-files/c.java"));
expected.add(new File("some-files/more-files/b.txt"));
expected.add(new File("some-files/a.txt"));
assertArrayEquals(expected.toArray(), FileExample.getFiles(file2).toArray());
}
@Test
public void testGetFiles3() throws IOException{
List<File> expected = new ArrayList<>();
File file3 = new File("some-files/a.txt");
expected.add(file3);
assertArrayEquals(expected.toArray(), FileExample.getFiles(file3).toArray());
}
}