Removed unnecessary main method. Changed assert methods to the one for comparing integers

This commit is contained in:
alfred.samanga@gmail.com 2019-08-17 08:09:15 +02:00
parent 0dcf126861
commit f9cf8eefe2
2 changed files with 4 additions and 8 deletions

View File

@ -3,10 +3,6 @@ package com.baeldung.string.wordcount;
import java.util.StringTokenizer;
public class WordCounter {
public static void main(String[] args) {
}
public static int countWordsUsingRegex(String arg) {
if (arg == null) {
return 0;

View File

@ -1,6 +1,6 @@
package com.baeldung.string.wordcount;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class WordCountUnitTest {
@ -9,16 +9,16 @@ public class WordCountUnitTest {
@Test
public void givenStringWith8Words_whenUsingRegexCount_ThenResultEqual8() {
assertThat(WordCounter.countWordsUsingRegex(string2) == 8).isTrue();
assertEquals(8, WordCounter.countWordsUsingRegex(string2));
}
@Test
public void givenStringWith8Words_whenUsingManualMethod_ThenWordCountEqual8() {
assertThat(WordCounter.countWordsManually(string1) == 8).isTrue();
assertEquals(8, WordCounter.countWordsManually(string1));
}
@Test
public void givenAStringWith8Words_whenUsingTokenizer_ThenWordCountEqual8() {
assertThat(WordCounter.countWordsUsingTokenizer(string1) == 8).isTrue();
assertEquals(8, WordCounter.countWordsUsingTokenizer(string1));
}
}