diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2017-09-06 01:53:52 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2017-09-06 01:53:52 +0000 |
commit | 392dfba3ef4ec2151ba9ac6772a3361d7b4e65f3 (patch) | |
tree | d6ccdbfc9ab25d6bd4211ec7f6e65b38da134c2f /src/test | |
parent | 8368b87ccd65ee13358e60ecdcfc1852e9b33d75 (diff) | |
download | jackcess-392dfba3ef4ec2151ba9ac6772a3361d7b4e65f3.tar.gz jackcess-392dfba3ef4ec2151ba9ac6772a3361d7b4e65f3.zip |
add some initial default function unit tests; fix some parse bugs
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1114 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java | 54 | ||||
-rw-r--r-- | src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java | 4 |
2 files changed, 56 insertions, 2 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 new file mode 100644 index 0000000..0e2e85e --- /dev/null +++ b/src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java @@ -0,0 +1,54 @@ +/* +Copyright (c) 2016 James Ahlborn + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package com.healthmarketscience.jackcess.impl.expr; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.healthmarketscience.jackcess.DatabaseBuilder; +import com.healthmarketscience.jackcess.TestUtil; +import com.healthmarketscience.jackcess.expr.EvalContext; +import com.healthmarketscience.jackcess.expr.Expression; +import com.healthmarketscience.jackcess.expr.Function; +import com.healthmarketscience.jackcess.expr.TemporalConfig; +import com.healthmarketscience.jackcess.expr.Value; +import junit.framework.TestCase; +import static com.healthmarketscience.jackcess.impl.expr.ExpressionatorTest.eval; + +/** + * + * @author James Ahlborn + */ +public class DefaultFunctionsTest extends TestCase +{ + + public DefaultFunctionsTest(String name) { + super(name); + } + + public void testFuncs() throws Exception + { + assertEquals("foo", eval("=IIf(10 > 1, \"foo\", \"bar\")")); + assertEquals("bar", eval("=IIf(10 < 1, \"foo\", \"bar\")")); + assertEquals(102L, eval("=Asc(\"foo\")")); + assertEquals(9786L, eval("=AscW(\"\u263A\")")); + assertEquals("f", eval("=Chr(102)")); + assertEquals("\u263A", eval("=ChrW(9786)")); + assertEquals("263A", eval("=Hex(9786)")); + } + +} 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 9bc7f49..b9b9b22 100644 --- a/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java +++ b/src/test/java/com/healthmarketscience/jackcess/impl/expr/ExpressionatorTest.java @@ -307,7 +307,7 @@ public class ExpressionatorTest extends TestCase assertEquals(cleanStr, expr.toString()); } - private static Object eval(String exprStr) { + static Object eval(String exprStr) { Expression expr = Expressionator.parse( Expressionator.Type.DEFAULT_VALUE, exprStr, new TestParseContext()); return expr.eval(new TestEvalContext(null)); @@ -342,7 +342,7 @@ public class ExpressionatorTest extends TestCase } public Function getExpressionFunction(String name) { - return null; + return DefaultFunctions.getFunction(name); } } |