From d50370e04a588f8d6fe02ba2ec871f356c430297 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Sat, 15 Nov 2014 14:48:48 +0000 Subject: [PATCH] more unit tests for unicode compression git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@893 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/DatabaseTest.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java index 6f101fa..93370bc 100644 --- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -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(); } -- 2.39.5