@@ -887,6 +887,7 @@ public void join_separatorIsNonString_throwsException() {
887
887
}
888
888
889
889
@ Test
890
+ @ TestParameters ("{string: '@', lastIndexOf: '@@', expectedResult: -1}" )
890
891
@ TestParameters ("{string: '', lastIndexOf: '', expectedResult: 0}" )
891
892
@ TestParameters ("{string: 'hello mellow', lastIndexOf: '', expectedResult: 12}" )
892
893
@ TestParameters ("{string: 'hello mellow', lastIndexOf: 'hello', expectedResult: 0}" )
@@ -953,21 +954,20 @@ public void lastIndexOf_unicode_success(String string, String lastIndexOf, int e
953
954
}
954
955
955
956
@ Test
957
+ @ TestParameters ("{lastIndexOf: '@@'}" )
956
958
@ TestParameters ("{lastIndexOf: ' '}" )
957
959
@ TestParameters ("{lastIndexOf: 'a'}" )
958
960
@ TestParameters ("{lastIndexOf: 'abc'}" )
959
961
@ TestParameters ("{lastIndexOf: '나'}" )
960
962
@ TestParameters ("{lastIndexOf: '😁'}" )
961
- public void lastIndexOf_onEmptyString_throwsException (String lastIndexOf ) throws Exception {
963
+ public void lastIndexOf_strLengthLessThanSubstrLength_returnsMinusOne (String lastIndexOf )
964
+ throws Exception {
962
965
CelAbstractSyntaxTree ast = COMPILER .compile ("''.lastIndexOf(indexOfParam)" ).getAst ();
963
966
CelRuntime .Program program = RUNTIME .createProgram (ast );
964
967
965
- CelEvaluationException exception =
966
- assertThrows (
967
- CelEvaluationException .class ,
968
- () -> program .eval (ImmutableMap .of ("indexOfParam" , lastIndexOf )));
968
+ Object evaluatedResult = program .eval (ImmutableMap .of ("s" , "" , "indexOfParam" , lastIndexOf ));
969
969
970
- assertThat (exception ). hasMessageThat (). contains ( "lastIndexOf failure: Offset out of range" );
970
+ assertThat (evaluatedResult ). isEqualTo (- 1 );
971
971
}
972
972
973
973
@ Test
0 commit comments