@@ -18,13 +18,10 @@ package org.camunda.feel.impl.builtin
1818
1919import org .scalatest .matchers .should .Matchers
2020import org .scalatest .flatspec .AnyFlatSpec
21- import org .camunda .feel ._
2221import org .camunda .feel .api .EvaluationFailureType .FUNCTION_INVOCATION_FAILURE
23- import org .camunda .feel .impl .{EvaluationResultMatchers , FeelEngineTest , FeelIntegrationTest }
24- import org .camunda .feel .syntaxtree ._
22+ import org .camunda .feel .impl .{EvaluationResultMatchers , FeelEngineTest }
2523
2624import java .time .LocalDate
27- import scala .math .BigDecimal .int2bigDecimal
2825
2926/** @author
3027 * Philipp
@@ -257,6 +254,21 @@ class BuiltinListFunctionsTest
257254 evaluateExpression(" sublist([1,2,3], 1, 2) " ) should returnResult(List (1 , 2 ))
258255 }
259256
257+ it should " return null if the start position is 0" in {
258+
259+ evaluateExpression(" sublist([1,2,3], 0) " ) should (returnNull() and reportFailure(
260+ failureType = FUNCTION_INVOCATION_FAILURE ,
261+ failureMessage =
262+ " Failed to invoke function 'sublist': start position must be a non-zero number"
263+ ))
264+
265+ evaluateExpression(" sublist([1,2,3], 0, 2) " ) should (returnNull() and reportFailure(
266+ failureType = FUNCTION_INVOCATION_FAILURE ,
267+ failureMessage =
268+ " Failed to invoke function 'sublist': start position must be a non-zero number"
269+ ))
270+ }
271+
260272 " A append() function" should " return list with item appended" in {
261273
262274 evaluateExpression(" append([1,2], 3) " ) should returnResult(List (1 , 2 , 3 ))
@@ -274,11 +286,28 @@ class BuiltinListFunctionsTest
274286 evaluateExpression(" insert before([1,3],2,2) " ) should returnResult(List (1 , 2 , 3 ))
275287 }
276288
289+ it should " return null if the position is 0" in {
290+
291+ evaluateExpression(" insert before([1,3],0,2) " ) should (returnNull() and reportFailure(
292+ failureType = FUNCTION_INVOCATION_FAILURE ,
293+ failureMessage =
294+ " Failed to invoke function 'insert before': position must be a non-zero number"
295+ ))
296+ }
297+
277298 " A remove() function" should " return list with item at _ removed" in {
278299
279300 evaluateExpression(" remove([1,1,3],2) " ) should returnResult(List (1 , 3 ))
280301 }
281302
303+ it should " return null if the position is 0" in {
304+
305+ evaluateExpression(" remove([1,2,3], 0) " ) should (returnNull() and reportFailure(
306+ failureType = FUNCTION_INVOCATION_FAILURE ,
307+ failureMessage = " Failed to invoke function 'remove': position must be a non-zero number"
308+ ))
309+ }
310+
282311 " A reverse() function" should " reverse the list" in {
283312
284313 evaluateExpression(" reverse([1,2,3]) " ) should returnResult(List (3 , 2 , 1 ))
0 commit comments