1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.inputmethod.latin; 18 19 import android.test.AndroidTestCase; 20 import android.test.suitebuilder.annotation.SmallTest; 21 22 import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions; 23 import com.android.inputmethod.latin.makedict.FusionDictionary; 24 import com.android.inputmethod.latin.makedict.ProbabilityInfo; 25 import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray; 26 27 import java.util.HashMap; 28 29 /** 30 * Unit test for FusionDictionary 31 */ 32 @SmallTest 33 public class FusionDictionaryTests extends AndroidTestCase { 34 public void testFindWordInTree() { 35 FusionDictionary dict = new FusionDictionary(new PtNodeArray(), 36 new DictionaryOptions(new HashMap<String,String>())); 37 38 dict.add("abc", new ProbabilityInfo(10), null, false /* isNotAWord */); 39 assertNull(FusionDictionary.findWordInTree(dict.mRootNodeArray, "aaa")); 40 assertNotNull(FusionDictionary.findWordInTree(dict.mRootNodeArray, "abc")); 41 42 dict.add("aa", new ProbabilityInfo(10), null, false /* isNotAWord */); 43 assertNull(FusionDictionary.findWordInTree(dict.mRootNodeArray, "aaa")); 44 assertNotNull(FusionDictionary.findWordInTree(dict.mRootNodeArray, "aa")); 45 46 dict.add("babcd", new ProbabilityInfo(10), null, false /* isNotAWord */); 47 dict.add("bacde", new ProbabilityInfo(10), null, false /* isNotAWord */); 48 assertNull(FusionDictionary.findWordInTree(dict.mRootNodeArray, "ba")); 49 assertNotNull(FusionDictionary.findWordInTree(dict.mRootNodeArray, "babcd")); 50 assertNotNull(FusionDictionary.findWordInTree(dict.mRootNodeArray, "bacde")); 51 } 52 } 53