aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2018-07-17 21:49:09 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2018-07-17 21:49:09 +0000
commitabe506f27c2d6c789eb53a43bcdbe0a258c596dd (patch)
tree6e125e88d8bd68d058ff80241690ec5b9bcff3b9 /src/test
parent18a4998e71e239bba1712109f456dbea80067867 (diff)
downloadjackcess-abe506f27c2d6c789eb53a43bcdbe0a258c596dd.tar.gz
jackcess-abe506f27c2d6c789eb53a43bcdbe0a258c596dd.zip
test number functions
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@1183 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java41
1 files changed, 41 insertions, 0 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 39e5da3..58d99e0 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
import com.healthmarketscience.jackcess.expr.EvalException;
import junit.framework.TestCase;
import static com.healthmarketscience.jackcess.impl.expr.ExpressionatorTest.eval;
+import static com.healthmarketscience.jackcess.impl.expr.ExpressionatorTest.toBD;
/**
*
@@ -171,6 +172,46 @@ public class DefaultFunctionsTest extends TestCase
}
}
+ public void testNumberFuncs() throws Exception
+ {
+ assertEquals(1, eval("=Abs(1)"));
+ assertEquals(1, eval("=Abs(-1)"));
+ assertEquals(toBD(1.1), eval("=Abs(-1.1)"));
+
+ assertEquals(Math.atan(0.2), eval("=Atan(0.2)"));
+ assertEquals(Math.sin(0.2), eval("=Sin(0.2)"));
+ assertEquals(Math.tan(0.2), eval("=Tan(0.2)"));
+ assertEquals(Math.cos(0.2), eval("=Cos(0.2)"));
+
+ assertEquals(Math.exp(0.2), eval("=Exp(0.2)"));
+ assertEquals(Math.log(0.2), eval("=Log(0.2)"));
+ assertEquals(Math.sqrt(4.3), eval("=Sqr(4.3)"));
+
+ assertEquals(3, eval("=Fix(3.5)"));
+ assertEquals(4, eval("=Fix(4)"));
+ assertEquals(-3, eval("=Fix(-3.5)"));
+ assertEquals(-4, eval("=Fix(-4)"));
+
+ assertEquals(1, eval("=Sgn(3.5)"));
+ assertEquals(1, eval("=Sgn(4)"));
+ assertEquals(-1, eval("=Sgn(-3.5)"));
+ assertEquals(-1, eval("=Sgn(-4)"));
+
+ assertEquals(3, eval("=Int(3.5)"));
+ assertEquals(4, eval("=Int(4)"));
+ assertEquals(-4, eval("=Int(-3.5)"));
+ assertEquals(-4, eval("=Int(-4)"));
+
+ assertEquals(toBD(4), eval("=Round(3.7)"));
+ assertEquals(4, eval("=Round(4)"));
+ assertEquals(toBD(-4), eval("=Round(-3.7)"));
+ assertEquals(-4, eval("=Round(-4)"));
+
+ assertEquals(toBD(3.73), eval("=Round(3.7345, 2)"));
+ assertEquals(4, eval("=Round(4, 2)"));
+ assertEquals(toBD(-3.73), eval("=Round(-3.7345, 2)"));
+ assertEquals(-4, eval("=Round(-4, 2)"));
+ }
public void testFinancialFuncs() throws Exception
{