From 0d35c159fefd7591c2ab9d5037c32d1804024197 Mon Sep 17 00:00:00 2001 From: Yuichiro Hanada Date: Fri, 17 Aug 2012 10:23:01 +0900 Subject: [PATCH] fix findWordInTree. Change-Id: I8f42df28f76188677db9d4e55885e1fc6a40b53f --- .../inputmethod/latin/makedict/FusionDictionary.java | 1 + .../android/inputmethod/latin/FusionDictionaryTests.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java index 260155174..7c15ba54d 100644 --- a/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java +++ b/java/src/com/android/inputmethod/latin/makedict/FusionDictionary.java @@ -532,6 +532,7 @@ public class FusionDictionary implements Iterable { } while (null != node && index < s.length()); if (index < s.length()) return null; + if (!currentGroup.isTerminal()) return null; if (DBG && !s.equals(checker.toString())) return null; return currentGroup; } diff --git a/tests/src/com/android/inputmethod/latin/FusionDictionaryTests.java b/tests/src/com/android/inputmethod/latin/FusionDictionaryTests.java index e3f75839e..8ecdcc366 100644 --- a/tests/src/com/android/inputmethod/latin/FusionDictionaryTests.java +++ b/tests/src/com/android/inputmethod/latin/FusionDictionaryTests.java @@ -38,5 +38,11 @@ public class FusionDictionaryTests extends AndroidTestCase { dict.add("aa", 10, null); assertNull(FusionDictionary.findWordInTree(dict.mRoot, "aaa")); assertNotNull(FusionDictionary.findWordInTree(dict.mRoot, "aa")); + + dict.add("babcd", 10, null); + dict.add("bacde", 10, null); + assertNull(FusionDictionary.findWordInTree(dict.mRoot, "ba")); + assertNotNull(FusionDictionary.findWordInTree(dict.mRoot, "babcd")); + assertNotNull(FusionDictionary.findWordInTree(dict.mRoot, "bacde")); } }