1
2
3
4
5
6
7
8
9
10
11
12
13
14 package ch.qos.logback.classic.corpusTest;
15
16 import java.io.BufferedReader;
17 import java.io.IOException;
18 import java.io.StringReader;
19 import java.util.List;
20
21 import ch.qos.logback.classic.corpus.TextFileUtil;
22 import org.junit.jupiter.api.Test;
23
24 import static org.junit.jupiter.api.Assertions.assertEquals;
25
26 public class TextFileUtilTest {
27
28 @Test
29 public void smoke() throws IOException {
30 String s = "When on board H.M.S. 'Beagle,' as naturalist, I was much struck with\r\n"
31 + "certain facts in the distribution of the inhabitants of South America,\r\n"
32 + "and in the geological relations of the present to the past inhabitants\r\n" + "of that continent.";
33
34 StringReader sr = new StringReader(s);
35 BufferedReader br = new BufferedReader(sr);
36 List<String> wordList = TextFileUtil.toWords(br);
37 assertEquals(38, wordList.size());
38 assertEquals("When", wordList.get(0));
39 assertEquals("'Beagle,'", wordList.get(4));
40 assertEquals("of", wordList.get(17));
41
42 }
43 }