Skip to content

Commit

Permalink
more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MherBaghinyan committed Jan 23, 2019
1 parent 5c1a0a0 commit 8c18214
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,59 @@ public class MatchWordsUnitTest {

private final String[] words = {"hello", "Baeldung"};
private final String inputString = "hello there, Baeldung";
private final String wholeInput = "helloBaeldung";

@Test
public void givenText_whenCallingStringContains_shouldMatchWords() {

final boolean result = MatchWords.containsWords(inputString, words);

assertThat(result).isEqualTo(true);
}

@Test
public void givenText_whenCallingJava8_shouldMatchWords() {

final boolean result = MatchWords.containsWordsJava8(inputString, words);

assertThat(result).isEqualTo(true);
}

@Test
public void givenText_whenCallingPattern_shouldMatchWords() {
public void givenText_whenCallingJava8_shouldNotMatchWords() {
final boolean result = MatchWords.containsWordsJava8(wholeInput, words);
assertThat(result).isEqualTo(false);
}

@Test
public void givenText_whenCallingPattern_shouldMatchWords() {
final boolean result = MatchWords.containsWordsPatternMatch(inputString, words);

assertThat(result).isEqualTo(true);
}

@Test
public void givenText_whenCallingAhoCorasick_shouldMatchWords() {

final boolean result = MatchWords.containsWordsAhoCorasick(inputString, words);

assertThat(result).isEqualTo(true);
}

@Test
public void givenText_whenCallingIndexOf_shouldMatchWords() {
public void givenText_whenCallingAhoCorasick_shouldNotMatchWords() {
final boolean result = MatchWords.containsWordsAhoCorasick(wholeInput, words);
assertThat(result).isEqualTo(false);
}

@Test
public void givenText_whenCallingIndexOf_shouldMatchWords() {
final boolean result = MatchWords.containsWordsIndexOf(inputString, words);

assertThat(result).isEqualTo(true);
}

@Test
public void givenText_whenCallingArrayList_shouldMatchWords() {

final boolean result = MatchWords.containsWordsArray(inputString, words);

assertThat(result).isEqualTo(true);
}

@Test
public void givenText_whenCallingArrayList_shouldNotMatchWords() {
final boolean result = MatchWords.containsWordsArray(wholeInput, words);
assertThat(result).isEqualTo(false);
}
}

0 comments on commit 8c18214

Please sign in to comment.