-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWordCountTest.java
More file actions
32 lines (26 loc) · 859 Bytes
/
WordCountTest.java
File metadata and controls
32 lines (26 loc) · 859 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
package com.example.modernjava.chapter07;
import com.example.modernjava.data.TextTestData;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@Slf4j
class WordCountTest {
private String sentence;
@BeforeEach
void setUp() {
sentence = String.join("", TextTestData.INFERNO);
}
@Test
void testCountWordsIteratively() {
final var result = WordCount.countWordsIteratively(sentence);
assertEquals(19, result);
log.info("Word count for sentence: {}", result);
}
@Test
void testCountWordsUsingStream() {
final var result = WordCount.countWordsUsingStream(sentence);
assertEquals(19, result);
log.info("Word count for sentence: {}", result);
}
}