]> gitweb.fperrin.net Git - DictionaryPC.git/blobdiff - src/com/hughes/android/dictionary/DictionaryTest.java
go
[DictionaryPC.git] / src / com / hughes / android / dictionary / DictionaryTest.java
index 43fb7ab407d324d4eb2653a16fa748c265f0a1fd..806e83627415937bf375139b9f06b2d2b43c3257 100755 (executable)
@@ -5,10 +5,12 @@ import java.io.IOException;
 import java.io.RandomAccessFile;\r
 import java.util.Arrays;\r
 import java.util.List;\r
+import java.util.concurrent.atomic.AtomicBoolean;\r
 \r
 import junit.framework.TestCase;\r
 \r
 import com.hughes.android.dictionary.Dictionary.IndexEntry;\r
+import com.hughes.android.dictionary.Dictionary.Language;\r
 import com.hughes.android.dictionary.Dictionary.Row;\r
 \r
 public class DictionaryTest extends TestCase {\r
@@ -17,7 +19,7 @@ public class DictionaryTest extends TestCase {
     final File file = File.createTempFile("asdf", "asdf");\r
     file.deleteOnExit();\r
 \r
-    final Dictionary goldenDict;\r
+//    final Dictionary goldenDict;\r
     final List<Entry> entries = Arrays.asList(\r
         new Entry("der Hund", "the dog"),\r
         new Entry("Die grosse Katze", "The big cat"), \r
@@ -37,7 +39,7 @@ public class DictionaryTest extends TestCase {
       dict.write(raf);\r
       raf.close();\r
       \r
-      goldenDict = dict;\r
+//      goldenDict = dict;\r
     }\r
 \r
     final RandomAccessFile raf = new RandomAccessFile(file, "r");\r
@@ -62,6 +64,35 @@ public class DictionaryTest extends TestCase {
       ++rowCount;\r
     }\r
 \r
+    for (int l = 0; l <= 1; l++) {\r
+      final Language lang = dict.languages[l];\r
+      for (int i = 0; i < lang.sortedIndex.size(); i++) {\r
+        final IndexEntry indexEntry = lang.sortedIndex.get(i);\r
+        if (indexEntry.word.toLowerCase().equals("dieb"))\r
+          System.out.println();\r
+        final IndexEntry lookedUpEntry = lang.sortedIndex.get(lang.lookup(indexEntry.word, new AtomicBoolean(false)));\r
+        if (!indexEntry.word.toLowerCase().equals(lookedUpEntry.word.toLowerCase()))\r
+          System.out.println();\r
+        assertEquals(indexEntry.word.toLowerCase(), lookedUpEntry.word.toLowerCase());\r
+      }\r
+    }\r
+    \r
+    assertEquals("Die", dict.languages[0].sortedIndex.get(dict.languages[0].lookup("die", new AtomicBoolean())).word);\r
+\r
+  }\r
+  \r
+  public void testTextNorm() throws IOException {\r
+//    final File file = File.createTempFile("asdf", "asdf");\r
+//    file.deleteOnExit();\r
+\r
+//      final Dictionary goldenDict;\r
+    final List<Entry> entries = Arrays.asList(\r
+        new Entry("der Hund", "the dog"),\r
+        new Entry("Die grosse Katze", "The big cat"), \r
+        new Entry("die Katze", "the cat"),\r
+        new Entry("gross", "big"),\r
+        new Entry("Dieb", "thief"),\r
+        new Entry("rennen", "run"));\r
 \r
   }\r
 \r