-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamExercisesTest.java
More file actions
executable file
·42 lines (36 loc) · 1.13 KB
/
Copy pathStreamExercisesTest.java
File metadata and controls
executable file
·42 lines (36 loc) · 1.13 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
import java.util.*;
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.nio.file.*;
import java.io.*;
public class StreamExercisesTest {
private static int TRIALS = 10000;
private static int SEED = 9999;
@Test
public void testCountLines() {
StreamExercises se = new StreamExercises();
try {
assertEquals(se.countLines(Paths.get("warandpeace.txt"), 70), 21079);
}
catch(IOException e) {
System.out.println("Unable to read warandpeace.txt!");
assertTrue(false);
}
}
@Test
public void testCollectWords() {
StreamExercises se = new StreamExercises();
try {
List<String> words = se.collectWords(Paths.get("warandpeace.txt"));
assertEquals(17465, words.size());
assertEquals("accomplished", words.get(100));
assertEquals("sundays", words.get(15000));
}
catch(IOException e) {
System.out.println("Unable to read warandpeace.txt!");
assertTrue(false);
}
}
}