1/* 2 * Copyright (C) 2011 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 17package com.android.inputmethod.latin; 18 19import com.android.inputmethod.latin.FusionDictionary.Node; 20 21import java.util.ArrayList; 22 23import junit.framework.TestCase; 24 25/** 26 * Unit tests for BinaryDictInputOutput. 27 */ 28public class BinaryDictInputOutputTest extends TestCase { 29 30 public void setUp() throws Exception { 31 super.setUp(); 32 } 33 34 public void tearDown() throws Exception { 35 super.tearDown(); 36 } 37 38 // Test the flattened array contains the expected number of nodes, and 39 // that it does not contain any duplicates. 40 public void testFlattenNodes() { 41 final FusionDictionary dict = new FusionDictionary(); 42 dict.add("foo", 1, null); 43 dict.add("fta", 1, null); 44 dict.add("ftb", 1, null); 45 dict.add("bar", 1, null); 46 dict.add("fool", 1, null); 47 final ArrayList<Node> result = BinaryDictInputOutput.flattenTree(dict.mRoot); 48 assertEquals(4, result.size()); 49 while (!result.isEmpty()) { 50 final Node n = result.remove(0); 51 assertFalse("Flattened array contained the same node twice", result.contains(n)); 52 } 53 } 54 55} 56