mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-27 02:48:04 +01:00
Add test for SimpleCharprefixTree.
This commit is contained in:
parent
e24ccc734a
commit
86da983cf8
@ -0,0 +1,39 @@
|
||||
package fr.neatmonster.nocheatplus.test;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import fr.neatmonster.nocheatplus.utilities.ds.prefixtree.SimpleCharPrefixTree;
|
||||
|
||||
public class TestSimpleCharPrefixTree {
|
||||
private List<String> feed = Arrays.asList(
|
||||
"op", "op dummy", "ncp info"
|
||||
);
|
||||
|
||||
private List<String> mustFind = Arrays.asList(
|
||||
"op", "op dummy", "ncp info", "ncp info test"
|
||||
);
|
||||
|
||||
private List<String> mustNotFind = Arrays.asList(
|
||||
"opp", "opp dummy", "op dummy2", "ncp", "ncp dummy"
|
||||
);
|
||||
|
||||
@Test
|
||||
public void testPrefixWords(){
|
||||
SimpleCharPrefixTree tree = new SimpleCharPrefixTree();
|
||||
tree.feedAll(feed, false, true);
|
||||
for (String input : mustFind){
|
||||
if (!tree.hasPrefixWords(input)){
|
||||
fail("Expect to be matched: '" + input + "'");
|
||||
}
|
||||
}
|
||||
for (String input : mustNotFind){
|
||||
if (tree.hasPrefixWords(input)){
|
||||
fail("Expect not to be matched: '" + input + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user