diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2007-06-05 02:21:55 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2007-06-05 02:21:55 +0000 |
commit | b0bc33f822e48f5973fd9f41cc123343ff5a8d02 (patch) | |
tree | 9c3c94186c47fbf230fb8d82734614fed6dae7e2 /test | |
parent | 5de2b053b8768c9a34aa2447a2b1d62ba0102f08 (diff) | |
download | jackcess-b0bc33f822e48f5973fd9f41cc123343ff5a8d02.tar.gz jackcess-b0bc33f822e48f5973fd9f41cc123343ff5a8d02.zip |
handle reading/writing numeric values which thing that they are fixed length fields (fix #1672071)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@148 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r-- | test/data/fixedNumericTest.mdb | bin | 0 -> 131072 bytes | |||
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java | 52 |
2 files changed, 52 insertions, 0 deletions
diff --git a/test/data/fixedNumericTest.mdb b/test/data/fixedNumericTest.mdb Binary files differnew file mode 100644 index 0000000..e329181 --- /dev/null +++ b/test/data/fixedNumericTest.mdb diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java index 449424d..7524133 100644 --- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -478,6 +478,7 @@ public class DatabaseTest extends TestCase { col.setScale((byte)4); col.setPrecision((byte)8); columns.add(col); + assertTrue(col.isVariableLength()); col = new Column(); col.setName("B"); @@ -523,6 +524,57 @@ public class DatabaseTest extends TestCase { } } + public void testFixedNumeric() throws Exception + { + File srcFile = new File("test/data/fixedNumericTest.mdb"); + File dbFile = File.createTempFile("databaseTest", ".mdb"); + dbFile.deleteOnExit(); + copyFile(srcFile, dbFile); + + Database db = Database.open(dbFile); + Table t = db.getTable("test"); + + boolean first = true; + for(Column col : t.getColumns()) { + if(first) { + assertTrue(col.isVariableLength()); + assertEquals(DataType.MEMO, col.getType()); + first = false; + } else { + assertFalse(col.isVariableLength()); + assertEquals(DataType.NUMERIC, col.getType()); + } + } + + Map<String, Object> row = t.getNextRow(); + assertEquals("some data", row.get("col1")); + assertEquals(new BigDecimal("1"), row.get("col2")); + assertEquals(new BigDecimal("0"), row.get("col3")); + assertEquals(new BigDecimal("0"), row.get("col4")); + assertEquals(new BigDecimal("4"), row.get("col5")); + assertEquals(new BigDecimal("-1"), row.get("col6")); + assertEquals(new BigDecimal("1"), row.get("col7")); + + Object[] tmpRow = new Object[]{ + "foo", new BigDecimal("1"), new BigDecimal(3), new BigDecimal("13"), + new BigDecimal("-17"), new BigDecimal("0"), new BigDecimal("8734")}; + t.addRow(tmpRow); + t.reset(); + + t.getNextRow(); + row = t.getNextRow(); + assertEquals(tmpRow[0], row.get("col1")); + assertEquals(tmpRow[1], row.get("col2")); + assertEquals(tmpRow[2], row.get("col3")); + assertEquals(tmpRow[3], row.get("col4")); + assertEquals(tmpRow[4], row.get("col5")); + assertEquals(tmpRow[5], row.get("col6")); + assertEquals(tmpRow[6], row.get("col7")); + + db.close(); + + } + public void testMultiPageTableDef() throws Exception { List<Column> columns = open().getTable("Table2").getColumns(); |