From b0bc33f822e48f5973fd9f41cc123343ff5a8d02 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Tue, 5 Jun 2007 02:21:55 +0000 Subject: 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 --- test/data/fixedNumericTest.mdb | Bin 0 -> 131072 bytes .../healthmarketscience/jackcess/DatabaseTest.java | 52 +++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/data/fixedNumericTest.mdb (limited to 'test') diff --git a/test/data/fixedNumericTest.mdb b/test/data/fixedNumericTest.mdb new file mode 100644 index 0000000..e329181 Binary files /dev/null and b/test/data/fixedNumericTest.mdb differ 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 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 columns = open().getTable("Table2").getColumns(); -- cgit v1.2.3