aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2018-07-25 02:30:33 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2018-07-25 02:30:33 +0000
commitb2aba90126da7421be9d30656354dda71d0de301 (patch)
tree6897003b0d78208f3ded756380ba0db94be38d20 /src/test
parent0080d0c36f03edc4a9c6478fe439fe2dfd4d45ca (diff)
downloadjackcess-b2aba90126da7421be9d30656354dda71d0de301.tar.gz
jackcess-b2aba90126da7421be9d30656354dda71d0de301.zip
add some date function tests
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1185 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java23
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java6
2 files changed, 26 insertions, 3 deletions
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java
index 58d99e0..461f153 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java
@@ -213,6 +213,29 @@ public class DefaultFunctionsTest extends TestCase
assertEquals(-4, eval("=Round(-4, 2)"));
}
+ public void testDateFuncs() throws Exception
+ {
+ assertEquals("1/2/2003", eval("=CStr(DateValue(#01/02/2003 7:00:00 AM#))"));
+ assertEquals("07:00:00 AM", eval("=CStr(TimeValue(#01/02/2003 7:00:00 AM#))"));
+
+ assertEquals(2003, eval("=Year(#01/02/2003 7:00:00 AM#)"));
+ assertEquals(1, eval("=Month(#01/02/2003 7:00:00 AM#)"));
+ assertEquals(2, eval("=Day(#01/02/2003 7:00:00 AM#)"));
+
+ assertEquals(7, eval("=Hour(#01/02/2003 7:10:27 AM#)"));
+ assertEquals(19, eval("=Hour(#01/02/2003 7:10:27 PM#)"));
+ assertEquals(10, eval("=Minute(#01/02/2003 7:10:27 AM#)"));
+ assertEquals(27, eval("=Second(#01/02/2003 7:10:27 AM#)"));
+
+ assertEquals(7, eval("=Weekday(#11/22/2003#)"));
+ assertEquals(3, eval("=Weekday(#11/22/2003#, 5)"));
+
+ assertTrue(((String)eval("=CStr(Date())"))
+ .matches("\\d{1,2}/\\d{1,2}/\\d{4}"));
+ assertTrue(((String)eval("=CStr(Time())"))
+ .matches("\\d{1,2}:\\d{1,2}:\\d{2} (AM|PM)"));
+ }
+
public void testFinancialFuncs() throws Exception
{
assertEquals("-9.57859403981317",
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java
index 5f6d9c2..8e077b0 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java
@@ -315,11 +315,11 @@ public class ExpressionatorTest extends TestCase
public void testDateArith() throws Exception
{
- assertEquals(new Date(1041508800000L), eval("=#01/02/2003# + #7:00:00#"));
- assertEquals(new Date(1041458400000L), eval("=#01/02/2003# - #7:00:00#"));
+ assertEquals(new Date(1041508800000L), eval("=#01/02/2003# + #7:00:00 AM#"));
+ assertEquals(new Date(1041458400000L), eval("=#01/02/2003# - #7:00:00 AM#"));
assertEquals(new Date(1044680400000L), eval("=#01/02/2003# + '37'"));
assertEquals(new Date(1044680400000L), eval("='37' + #01/02/2003#"));
- assertEquals(new Date(1041508800000L), eval("=#01/02/2003 7:00:00#"));
+ assertEquals(new Date(1041508800000L), eval("=#01/02/2003 7:00:00 AM#"));
}
public void testNull() throws Exception