forked from b0noI/AIF2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request b0noI#244 from Memtos/issue216
Issue 216
- Loading branch information
Showing
4 changed files
with
58 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 26 additions & 17 deletions
43
src/test/unit/java/io/aif/language/word/dict/WordTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,50 @@ | ||
package io.aif.language.word.dict; | ||
|
||
import io.aif.language.word.IWord; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Test; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static org.testng.Assert.*; | ||
|
||
public class WordTest { | ||
|
||
private final String ROOT_TOKEN = "hey"; | ||
private final Set<String> TOKENS = new HashSet<>(); | ||
|
||
@BeforeMethod | ||
public void setUp() { | ||
TOKENS.add("hey"); | ||
TOKENS.add("heya"); | ||
TOKENS.add("freya"); | ||
} | ||
private Collection<String> TOKENS = Arrays.asList("hey", "hey", "hey", "heya", "freya.", "freya"); | ||
|
||
@Test(groups = "unit-tests") | ||
public void testGetRootToken() throws Exception { | ||
IWord word = new Word(ROOT_TOKEN, TOKENS, (long) TOKENS.size()); | ||
assertEquals(ROOT_TOKEN, word.getRootToken()); | ||
assertEquals(word.getRootToken(), ROOT_TOKEN); | ||
} | ||
|
||
@Test(groups = "unit-tests") | ||
public void testGetAllTokens() throws Exception { | ||
IWord word = new Word(ROOT_TOKEN, TOKENS, (long) TOKENS.size()); | ||
assertEquals(TOKENS, word.getAllTokens()); | ||
Collection<String> TOKENS_ONCE = Arrays.asList("aa", "bb", "cc"); | ||
IWord word = new Word(ROOT_TOKEN, TOKENS_ONCE, (long) TOKENS_ONCE.size()); | ||
assertEquals(word.getAllTokens(), TOKENS_ONCE); | ||
} | ||
|
||
@Test(groups = "unit-tests") | ||
public void testGetCount() throws Exception { | ||
IWord word = new Word(ROOT_TOKEN, TOKENS, (long) TOKENS.size()); | ||
final Long actual = new Long(TOKENS.size()); | ||
assertEquals(actual, word.getCount()); | ||
assertEquals(word.getCount(), new Long(TOKENS.size())); | ||
} | ||
|
||
@Test(groups = "unit-tests") | ||
public void testGetTokenCountTest1() throws Exception { | ||
Word word = new Word(ROOT_TOKEN, TOKENS, (long) TOKENS.size()); | ||
assertEquals(word.getTokenCount("hey"), 3); | ||
} | ||
|
||
@Test(groups = "unit-tests") | ||
public void testGetTokenCountTest2() throws Exception { | ||
Word word = new Word(ROOT_TOKEN, TOKENS, (long) TOKENS.size()); | ||
assertEquals(word.getTokenCount("freya"), 1); | ||
} | ||
|
||
@Test(groups = "unit-tests") | ||
public void testGetTokenCountTest3() throws Exception { | ||
Word word = new Word(ROOT_TOKEN, TOKENS, (long) TOKENS.size()); | ||
assertEquals(word.getTokenCount("newToken"), 0); | ||
} | ||
} |