Search in sources :

Example 1 with CELError

use of org.projectnessie.cel.common.CELError in project cel-java by projectnessie.

the class ParserTest method expressionSizeCodePointLimit.

@Test
void expressionSizeCodePointLimit() {
    assertThatThrownBy(() -> new Parser(Options.builder().macros(Macro.AllMacros).expressionSizeCodePointLimit(-2).build())).isInstanceOf(IllegalArgumentException.class).hasMessage("expression size code point limit must be greater than or equal to -1: -2");
    Parser p = new Parser(Options.builder().macros(Macro.AllMacros).expressionSizeCodePointLimit(2).build());
    Source src = Source.newTextSource("foo");
    ParseResult parseResult = p.parse(src);
    assertThat(parseResult.getErrors().getErrors()).containsExactly(new CELError(Location.newLocation(-1, -1), "expression code point size exceeds limit: size: 3, limit 2"));
}
Also used : CELError(org.projectnessie.cel.common.CELError) ParseResult(org.projectnessie.cel.parser.Parser.ParseResult) Source(org.projectnessie.cel.common.Source) MethodSource(org.junit.jupiter.params.provider.MethodSource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 CELError (org.projectnessie.cel.common.CELError)1 Source (org.projectnessie.cel.common.Source)1 ParseResult (org.projectnessie.cel.parser.Parser.ParseResult)1