@Test public void testMakeInitialArray() { int[] indexArray = search.makeIndexArray(); boolean ok = true; for (int i = 0; i < indexArray.length; i++) { ok = ok && (indexArray[i] == -1); } Assert.assertTrue(ok); }
@Test public void testMakeTestPhrase() { int[] indexArray = search.makeIndexArray(); wordlist.addWord("this"); wordlist.addWord("isa"); wordlist.addWord("test"); indexArray[0] = 0; indexArray[1] = 1; indexArray[2] = 2; String phrase = search.makePhrase(indexArray); Assert.assertEquals("this isa test", phrase); }
@Test public void testMatching() throws NoSuchAlgorithmException { search.setMatcher(new MatcherForMd5(matchingMd5)); int[] indexArray = search.makeIndexArray(); wordlist.addWord("poultry"); wordlist.addWord("outwits"); wordlist.addWord("ants"); indexArray[0] = 0; indexArray[1] = 1; indexArray[2] = 2; String probe = testPhrase.replace(" ", ""); Assert.assertEquals(testPhrase, search.makePhrase(indexArray)); Assert.assertTrue(search.matching(probe, indexArray)); }
@Test public void testMakeEmptyPhrase() { int[] indexArray = search.makeIndexArray(); String phrase = search.makePhrase(indexArray); Assert.assertEquals("", phrase); }