diff options
Diffstat (limited to 'src/test/java')
-rw-r--r-- | src/test/java/org/javacs/StringSearchTest.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/test/java/org/javacs/StringSearchTest.java b/src/test/java/org/javacs/StringSearchTest.java index 7827fcd..b11efde 100644 --- a/src/test/java/org/javacs/StringSearchTest.java +++ b/src/test/java/org/javacs/StringSearchTest.java @@ -11,8 +11,13 @@ public class StringSearchTest { assertThat(got, equalTo(index)); } + private void testNextWord(String pat, String text, int index) { + var got = new StringSearch(pat).nextWord(text); + assertThat(got, equalTo(index)); + } + @Test - public void testFinderNext() { + public void testNext() { testNext("", "", 0); testNext("", "abc", 0); testNext("abc", "", -1); @@ -29,4 +34,24 @@ public class StringSearchTest { testNext("baa", "aaaaa", -1); testNext("at that", "which finally halts. at that point", 22); } + + @Test + public void testNextWord() { + testNextWord("", "", 0); + testNextWord("", "abc", -1); + testNextWord("abc", "", -1); + testNextWord("abc", "abc", 0); + testNextWord("d", "abcdefg", -1); + testNextWord("d", "abc d efg", 4); + testNextWord("nan", "banana", -1); + testNextWord("nan", "ba nan a", 3); + testNextWord("abcd", "abc", -1); + testNextWord("abcd", "bcd", -1); + testNextWord("bcd", "abcd", -1); + testNextWord("bcd", "a bcd", 2); + testNextWord("abc", "abc d", 0); + testNextWord("aa", "aaa", -1); + testNextWord("aa", "a aa", 2); + testNextWord("aa", "aa a", 0); + } } |