aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Laurent Le Brun <laurentlb@google.com>2017-03-20 16:59:12 +0000
committerGravatar Yue Gan <yueg@google.com>2017-03-21 12:49:58 +0000
commit20424c4ad7166a9683de812cab5eed6f8f3425fc (patch)
tree77fb1bbc0133e92e374112f9fc33dc87ea69a097 /src/test
parent8594de82e367fb463f2d02d3adda25fc99de9a9f (diff)
Make the spell checker a bit more conservative.
Reduce the max spell-checking distance for matching words. "target" will not match "range" anymore. -- PiperOrigin-RevId: 150638073 MOS_MIGRATED_REVID=150638073
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/util/SpellCheckerTest.java24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/util/SpellCheckerTest.java b/src/test/java/com/google/devtools/build/lib/util/SpellCheckerTest.java
index 5b4e55d4df..5ff97e8715 100644
--- a/src/test/java/com/google/devtools/build/lib/util/SpellCheckerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/util/SpellCheckerTest.java
@@ -84,8 +84,9 @@ public class SpellCheckerTest {
@Test
public void suggest() throws Exception {
List<String> dict = Lists.newArrayList(
- "isalnum", "isalpha", "isdigit", "islower", "isupper", "find", "join",
- "rsplit", "rstrip", "split", "splitlines", "startswith", "strip", "title", "upper");
+ "isalnum", "isalpha", "isdigit", "islower", "isupper", "find", "join", "range",
+ "rsplit", "rstrip", "split", "splitlines", "startswith", "strip", "title", "upper",
+ "x", "xyz");
assertThat(SpellChecker.suggest("isdfit", dict)).isEqualTo("isdigit");
assertThat(SpellChecker.suggest("rspit", dict)).isEqualTo("rsplit");
@@ -95,12 +96,17 @@ public class SpellCheckerTest {
assertThat(SpellChecker.suggest("fird", dict)).isEqualTo("find");
assertThat(SpellChecker.suggest("stip", dict)).isEqualTo("strip");
assertThat(SpellChecker.suggest("isAln", dict)).isEqualTo("isalnum");
-
- assertThat(SpellChecker.suggest("isAl", dict)).isEqualTo(null);
- assertThat(SpellChecker.suggest("", dict)).isEqualTo(null);
- assertThat(SpellChecker.suggest("f", dict)).isEqualTo(null);
- assertThat(SpellChecker.suggest("fir", dict)).isEqualTo(null);
- assertThat(SpellChecker.suggest("wqevxc", dict)).isEqualTo(null);
- assertThat(SpellChecker.suggest("ialsnuaip", dict)).isEqualTo(null);
+ assertThat(SpellChecker.suggest("targe", dict)).isEqualTo("range");
+ assertThat(SpellChecker.suggest("rarget", dict)).isEqualTo("range");
+ assertThat(SpellChecker.suggest("xyw", dict)).isEqualTo("xyz");
+
+ assertThat(SpellChecker.suggest("target", dict)).isNull();
+ assertThat(SpellChecker.suggest("isAl", dict)).isNull();
+ assertThat(SpellChecker.suggest("", dict)).isNull();
+ assertThat(SpellChecker.suggest("f", dict)).isNull();
+ assertThat(SpellChecker.suggest("fir", dict)).isNull();
+ assertThat(SpellChecker.suggest("wqevxc", dict)).isNull();
+ assertThat(SpellChecker.suggest("ialsnuaip", dict)).isNull();
+ assertThat(SpellChecker.suggest("xy", dict)).isNull();
}
}