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