Implement index-of expression (#1113)

This commit is contained in:
Siarhei Fedartsou
2023-05-09 00:16:58 +02:00
committed by GitHub
parent d716636d83
commit 379b1fc606
15 changed files with 458 additions and 1 deletions

View File

@@ -455,6 +455,27 @@ class ExpressionTest {
Assert.assertTrue("expression should match", Arrays.deepEquals(expected, actual))
}
@Test
@Throws(Exception::class)
fun testIndexOf() {
val expected = arrayOf<Any>("index-of", 2f, arrayOf<Any>("literal", arrayOf<Any>(1f, 2f, 3f)))
val actual =
Expression.indexOf(Expression.literal(2f), Expression.literal(arrayOf<Any>(1f, 2f, 3f)))
.toArray()
Assert.assertTrue("expression should match", Arrays.deepEquals(expected, actual))
}
@Test
@Throws(Exception::class)
fun testIndexOfWithFromIndex() {
val expected = arrayOf<Any>("index-of", 2f, arrayOf<Any>("literal", arrayOf<Any>(1f, 2f, 3f)), 1f)
val actual =
Expression.indexOf(Expression.literal(2f), Expression.literal(arrayOf<Any>(1f, 2f, 3f)), Expression.literal(1f))
.toArray()
Assert.assertTrue("expression should match", Arrays.deepEquals(expected, actual))
}
@Test
@Throws(Exception::class)
fun testInNumber() {