-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTailTest.java
More file actions
executable file
·32 lines (29 loc) · 960 Bytes
/
Copy pathTailTest.java
File metadata and controls
executable file
·32 lines (29 loc) · 960 Bytes
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
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.Random;
import java.io.*;
import java.util.*;
import java.util.zip.CRC32;
public class TailTest {
@Test
public void scanWarAndPeace() throws IOException {
CRC32 check = new CRC32();
int totalLines = 0;
for(int k = 10; k <= 100000; k = k * 10) {
Tail tail = new Tail(k);
BufferedReader fr = new BufferedReader(
new InputStreamReader(new FileInputStream("warandpeace.txt"), "UTF-8")
);
List<String> result = tail.processFile(fr);
totalLines += result.size();
fr.close();
for(String line: result) {
check.update(line.getBytes());
}
}
assertEquals(10 + 100 + 1000 + 10000 + 63852, totalLines);
assertEquals(1946545910L, check.getValue());
}
}