diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2006-07-25 19:27:16 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2006-07-25 19:27:16 +0000 |
commit | 78739630bdbdd5ae5021c981c10fffff773fa3b0 (patch) | |
tree | 0cf866810aa3a195b35d5c27a9bb6caf29a60fbf /test | |
parent | f495acf15344bf72147b6c7c62f6a076093e6014 (diff) | |
download | jackcess-78739630bdbdd5ae5021c981c10fffff773fa3b0.tar.gz jackcess-78739630bdbdd5ae5021c981c10fffff773fa3b0.zip |
add currency support
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@68 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'test')
-rw-r--r-- | test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java index 86f1bdd..ac42b08 100644 --- a/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/DatabaseTest.java @@ -4,7 +4,9 @@ package com.healthmarketscience.jackcess; import java.io.File; import java.io.FileNotFoundException; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.Arrays; import java.util.Calendar; import java.util.Date; import java.util.HashMap; @@ -216,6 +218,7 @@ public class DatabaseTest extends TestCase { Table table = db.getTable("Test"); table.addRow(new Object[]{testStr, testStr}); + table.reset(); Map<String, Object> row = table.getNextRow(); @@ -287,6 +290,43 @@ public class DatabaseTest extends TestCase { } } + public void testCurrency() throws Exception { + Database db = create(); + + List<Column> columns = new ArrayList<Column>(); + Column col = new Column(); + col.setName("A"); + col.setType(DataType.MONEY); + columns.add(col); + db.createTable("test", columns); + + Table table = db.getTable("Test"); + table.addRow(new BigDecimal("-2341234.03450")); + table.addRow(37L); + table.addRow(new BigDecimal("10000.45")); + + table.reset(); + + List<Object> foundValues = new ArrayList<Object>(); + Map<String, Object> row = null; + while((row = table.getNextRow()) != null) { + foundValues.add(row.get("A")); + } + + assertEquals(Arrays.asList( + new BigDecimal("-2341234.0345"), + new BigDecimal("37.0000"), + new BigDecimal("10000.4500")), + foundValues); + + try { + table.addRow(new BigDecimal("342523234145343543.3453")); + fail("ArithmeticException should have been thrown"); + } catch(ArithmeticException e) { + // ignored + } + } + private Object[] createTestRow() { return new Object[] {"Tim", "R", "McCune", 1234, (byte) 0xad, 555.66d, 777.88f, (short) 999, new Date()}; |