📄 dictionarytest.java
字号:
/**
*
*/
package org.solol.mmseg.test;
import org.solol.mmseg.core.IDictionary;
import org.solol.mmseg.core.IWord;
import org.solol.mmseg.internal.Dictionary;
import org.solol.mmseg.internal.Word;
import junit.framework.TestCase;
/**
* @author solo L
*
*/
public class DictionaryTest extends TestCase {
IDictionary dictionary = new Dictionary();
String word1Value = "我们";
IWord word1 = new Word(word1Value,Word.CJK_WORD);
String word2Value = "是";
IWord word2 = new Word(word2Value,Word.CJK_WORD);
String word3Value = "中学生";
IWord word3 = new Word(word3Value,Word.CJK_WORD);
String word4Value = "学生";
IWord word4 = new Word(word4Value,Word.CJK_WORD);
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
dictionary.addWord(word1Value,Word.CJK_WORD);
dictionary.addWord(word2Value,Word.CJK_WORD);
dictionary.addWord(word3Value,Word.CJK_WORD);
}
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
}
public final void testIsMatched() {
assertTrue(dictionary.isMatched(word1Value));
assertTrue(dictionary.isMatched(word2Value));
assertTrue(dictionary.isMatched(word3Value));
assertFalse(dictionary.isMatched(word4Value));
}
public final void testAddWord() {
dictionary.addWord(word4Value,Word.CJK_WORD);
assertTrue(dictionary.isMatched(word4Value));
dictionary.removeWord(word4Value);
assertFalse(dictionary.isMatched(word4Value));
}
public final void testGetWord() {
assertEquals(word1, dictionary.getWord(word1Value));
assertEquals(word2, dictionary.getWord(word2Value));
assertEquals(word3, dictionary.getWord(word3Value));
}
public final void testRemoveWord() {
dictionary.addWord(word4Value,Word.CJK_WORD);
assertTrue(dictionary.isMatched(word4Value));
dictionary.removeWord(word4Value);
assertFalse(dictionary.isMatched(word4Value));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -