aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2018-06-26 02:39:20 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2018-06-26 02:39:20 +0000
commitf495fcc761bcb275215f0d7d81b0135d8db56e2a (patch)
tree4500eb2ab3e081729910f18a047eefb7a47aa370 /src/test
parent2faf773bb91bccafcddd67c914bd5b38f5e99162 (diff)
downloadjackcess-f495fcc761bcb275215f0d7d81b0135d8db56e2a.tar.gz
jackcess-f495fcc761bcb275215f0d7d81b0135d8db56e2a.zip
add some tests for functions; fix said functions
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/exprs@1166 f203690c-595d-4dc9-a70b-905162fa7fd2
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java26
1 files changed, 25 insertions, 1 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 981c4d3..0b02888 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/expr/DefaultFunctionsTest.java
@@ -76,7 +76,31 @@ public class DefaultFunctionsTest extends TestCase
assertEquals("9786", eval("=CStr(9786)"));
assertEquals("-42", eval("=CStr(-42)"));
- // FIXME, instr, instrrev
+ assertEquals(2, eval("=InStr('AFOOBAR', 'FOO')"));
+ assertEquals(2, eval("=InStr('AFOOBAR', 'foo')"));
+ assertEquals(2, eval("=InStr(1, 'AFOOBAR', 'foo')"));
+ assertEquals(0, eval("=InStr(1, 'AFOOBAR', 'foo', 0)"));
+ assertEquals(2, eval("=InStr(1, 'AFOOBAR', 'foo', 1)"));
+ assertEquals(2, eval("=InStr(1, 'AFOOBAR', 'FOO', 0)"));
+ assertEquals(2, eval("=InStr(2, 'AFOOBAR', 'FOO')"));
+ assertEquals(0, eval("=InStr(3, 'AFOOBAR', 'FOO')"));
+ assertEquals(0, eval("=InStr(17, 'AFOOBAR', 'FOO')"));
+ assertEquals(2, eval("=InStr(1, 'AFOOBARFOOBAR', 'FOO')"));
+ assertEquals(8, eval("=InStr(3, 'AFOOBARFOOBAR', 'FOO')"));
+ assertNull(eval("=InStr(3, Null, 'FOO')"));
+
+ assertEquals(2, eval("=InStrRev('AFOOBAR', 'FOO')"));
+ assertEquals(2, eval("=InStrRev('AFOOBAR', 'foo')"));
+ assertEquals(2, eval("=InStrRev('AFOOBAR', 'foo', -1)"));
+ assertEquals(0, eval("=InStrRev('AFOOBAR', 'foo', -1, 0)"));
+ assertEquals(2, eval("=InStrRev('AFOOBAR', 'foo', -1, 1)"));
+ assertEquals(2, eval("=InStrRev('AFOOBAR', 'FOO', -1, 0)"));
+ assertEquals(2, eval("=InStrRev('AFOOBAR', 'FOO', 4)"));
+ assertEquals(0, eval("=InStrRev('AFOOBAR', 'FOO', 3)"));
+ assertEquals(2, eval("=InStrRev('AFOOBAR', 'FOO', 17)"));
+ assertEquals(2, eval("=InStrRev('AFOOBARFOOBAR', 'FOO', 9)"));
+ assertEquals(8, eval("=InStrRev('AFOOBARFOOBAR', 'FOO', 10)"));
+ assertNull(eval("=InStrRev(Null, 'FOO', 3)"));
assertEquals("FOOO", eval("=UCase(\"fOoO\")"));
assertEquals("fooo", eval("=LCase(\"fOoO\")"));