]> gitweb.fperrin.net Git - DictionaryPC.git/blobdiff - src/com/hughes/android/dictionary/engine/DictionaryBuilderTest.java
Apache license.
[DictionaryPC.git] / src / com / hughes / android / dictionary / engine / DictionaryBuilderTest.java
index e68bf5e29aceccb23427e2c7260ff3affacd46fe..4cd4fe3869f7388ff73aea27955fdb5eed631be3 100644 (file)
@@ -1,3 +1,17 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package com.hughes.android.dictionary.engine;
 
 import java.io.File;
@@ -11,8 +25,51 @@ import junit.framework.TestCase;
 
 public class DictionaryBuilderTest extends TestCase {
   
-  public void testGermanCombined() throws IOException {
-    final File result = new File("testdata/de_en.dict");
+  public void testWiktionaryItalian() throws Exception {
+    final File result = new File("testdata/wiktionary.it.quickdic");
+    System.out.println("Writing to: " + result);
+    DictionaryBuilder.main(new String[] {
+        "--dictOut=" + result.getAbsolutePath(),
+        "--lang1=IT",
+        "--lang2=EN",
+        "--dictInfo=SomeWikiData",
+
+        /*
+        "--input3=wikiSplit/english.data",
+        "--input3Name=enwiktionary.english",
+        "--input3Format=enwiktionary",
+        "--input3LangPattern=Italian",
+        "--input3LangCodePattern=it",
+        "--input3EnIndex=2",
+        "--input3PageLimit=1000",
+*/
+        "--input4=wikiSplit/italian.data",
+        "--input4Name=enwiktionary.italian",
+        "--input4Format=enwiktionary",
+        "--input4LangPattern=Italian",
+        "--input4LangCodePattern=it",
+        "--input4EnIndex=2",
+        "--input4PageLimit=1000",
+
+        "--print=testdata/wiktionary.it.test",
+    });
+    
+    // Check it once:
+    assertFilesEqual("testdata/wiktionary.it.golden2", "testdata/wiktionary.it.test"); 
+    
+    
+    // Check it again.
+    final Dictionary dict = new Dictionary(new RandomAccessFile(result.getAbsolutePath(), "r"));
+    final PrintStream out = new PrintStream(new File("testdata/wiktionary.it.test"));
+    dict.print(out);
+    out.close();
+    
+    assertFilesEqual("testdata/wiktionary.it.golden", "testdata/wiktionary.it.test");
+  }
+
+  
+  public void testGermanCombined() throws Exception {
+    final File result = new File("testdata/de-en.quickdic");
     System.out.println("Writing to: " + result);
     DictionaryBuilder.main(new String[] {
         "--dictOut=" + result.getAbsolutePath(),
@@ -21,7 +78,7 @@ public class DictionaryBuilderTest extends TestCase {
         "--dictInfo=@testdata/de-en_dictInfo.txt",
 
         "--input1=testdata/de-en_chemnitz_100",
-        "--input1Name=dictcc",
+        "--input1Name=chemnitz",
         "--input1Charset=UTF8",
         "--input1Format=chemnitz",
 
@@ -29,23 +86,24 @@ public class DictionaryBuilderTest extends TestCase {
         "--input2Name=dictcc",
         "--input2Charset=UTF8",
         "--input2Format=dictcc",
-        
+
         "--print=testdata/de-en.test",
     });
     
     // Check it once:
-    assertFilesEqual("testdata/de_en.golden", "testdata/de_en.test"); 
+    assertFilesEqual("testdata/de-en.golden", "testdata/de-en.test"); 
     
     
     // Check it again.
     final Dictionary dict = new Dictionary(new RandomAccessFile(result.getAbsolutePath(), "r"));
-    final PrintStream out = new PrintStream(new File("testdata/de_en.test"));
+    final PrintStream out = new PrintStream(new File("testdata/de-en.test"));
     dict.print(out);
     out.close();
     
-    assertFilesEqual("testdata/de_en.golden", "testdata/de_en.test");
+    assertFilesEqual("testdata/de-en.golden", "testdata/de-en.test");
   }
-  
+
+
 
   void assertFilesEqual(final String expected, final String actual) throws IOException {
     final String expectedString = FileUtil.readToString(new File(expected));
@@ -53,4 +111,5 @@ public class DictionaryBuilderTest extends TestCase {
     assertEquals(expectedString, actualString);
   }
 
+  
 }