-
Notifications
You must be signed in to change notification settings - Fork 0
/
LongestWord.test.java
29 lines (22 loc) · 967 Bytes
/
LongestWord.test.java
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
import org.junit.jupiter.api.Test;
import java.io.BufferedReader;
import java.io.StringReader;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class LongestWordTest {
@Test
public void testFindLongestWordInLine() {
LongestWord longestWord = new LongestWord();
assertEquals("elephant", longestWord.findLongestWordInLine("cat dog elephant"));
assertEquals("ab", longestWord.findLongestWordInLine("a ab"));
assertEquals("", longestWord.findLongestWordInLine(""));
}
@Test
public void testProcessFile() throws IOException {
LongestWord longestWord = new LongestWord();
String input = "apple banana\nthis is a test\nhello world";
BufferedReader in = new BufferedReader(new StringReader(input));
// You'd ideally want to capture console output and verify it
// For now, just ensuring no exceptions are thrown
longestWord.processFile(in);
}
}