diff options
author | George Fraser <george@fivetran.com> | 2018-12-30 00:00:48 -0800 |
---|---|---|
committer | George Fraser <george@fivetran.com> | 2018-12-30 00:00:48 -0800 |
commit | 9b3e6f044d3a37b4d27734ddee9e7bf1aa1f9c7b (patch) | |
tree | 230359f738fb9913c756c7466c637b9584a2089f /src/test/java | |
parent | a21ed1db810a37cd3793116f9b46fce873fff5ca (diff) | |
download | java-language-server-9b3e6f044d3a37b4d27734ddee9e7bf1aa1f9c7b.zip |
Use boyer-moore for word searches
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); + } } |