]> source.dussan.org Git - jackcess.git/commitdiff
more unit tests for unicode compression
authorJames Ahlborn <jtahlborn@yahoo.com>
Sat, 15 Nov 2014 14:48:48 +0000 (14:48 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Sat, 15 Nov 2014 14:48:48 +0000 (14:48 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@893 f203690c-595d-4dc9-a70b-905162fa7fd2

src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java

index 6f101fa38828c047424c6b74183b8689832cb204..93370bc1b12a4c2de1df817e67017b58d587a5fc 100644 (file)
@@ -1501,6 +1501,7 @@ public class DatabaseTest extends TestCase
     for(int i = 1; i <= 0xFF; ++i) {
       sb.append((char)i);
     }
+    String longStr = sb.toString();
 
     String[] expectedStrs = {
       "only ascii chars",
@@ -1510,14 +1511,39 @@ public class DatabaseTest extends TestCase
       "\u6F22\u5B57\u4EEE\u540D\u4EA4\u3058\u308A\u6587",
       "3L9\u001D52\u0002_AB(\u00A5\u0005!!V",
       "\u00FCmlaut",
-      sb.toString()};
+      longStr
+    };
 
-    for(Row row : db.getTable("Table")) {
+    Table t = db.getTable("Table");
+    for(Row row : t) {
       int id = (Integer)row.get("ID");
       String str = (String)row.get("Unicode");
       assertEquals(expectedStrs[id-1], str);
     }
 
+
+    ColumnImpl col = (ColumnImpl)t.getColumn("Unicode");
+
+    ByteBuffer bb = col.write(longStr, 1000);
+
+    assertEquals(longStr.length() + 2, bb.remaining());
+
+    byte[] bytes = new byte[bb.remaining()];
+    bb.get(bytes);
+    assertEquals(longStr, col.read(bytes));
+
+
+    longStr = longStr.replace('a', '\u0440');
+
+    bb = col.write(longStr, 1000);
+
+    assertEquals(longStr.length() * 2, bb.remaining());
+
+    bytes = new byte[bb.remaining()];
+    bb.get(bytes);
+    assertEquals(longStr, col.read(bytes));
+    
+
     db.close();
   }