MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestParserOptionErrors

Function TestParserOptionErrors

parser/parser_test.go:2335–2354  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2333}
2334
2335func TestParserOptionErrors(t *testing.T) {
2336 if _, err := NewParser(Macros(AllMacros...), MaxRecursionDepth(-2)); err == nil {
2337 t.Fatalf("got %q, want %q", err, "max recursion depth must be greater than or equal to -1: -2")
2338 }
2339 if _, err := NewParser(ErrorRecoveryLimit(-2)); err == nil {
2340 t.Fatalf("got %q, want %q", err, "error recovery limit must be greater than or equal to -1: -2")
2341 }
2342 if _, err := NewParser(ErrorRecoveryLookaheadTokenLimit(0)); err == nil {
2343 t.Fatalf("got %q, want %q", err, "error recovery lookahead token limit must be at least 1: 0")
2344 }
2345 if _, err := NewParser(ErrorReportingLimit(0)); err == nil {
2346 t.Fatalf("got %q, want %q", err, "error reporting limit must be greater than 0: -2")
2347 }
2348 if _, err := NewParser(ExpressionSizeCodePointLimit(-2)); err == nil {
2349 t.Fatalf("got %q, want %q", err, "expression size code point limit must be greater than or equal to -1: -2")
2350 }
2351 if _, err := NewParser(MaxExpressionNodeCount(-2)); err == nil {
2352 t.Fatalf("got %q, want %q", err, "max expression node count must be greater than or equal to -1: -2")
2353 }
2354}
2355
2356func BenchmarkParse(b *testing.B) {
2357 p, err := NewParser(

Callers

nothing calls this directly

Calls 8

MaxRecursionDepthFunction · 0.85
ErrorRecoveryLimitFunction · 0.85
ErrorReportingLimitFunction · 0.85
MaxExpressionNodeCountFunction · 0.85
NewParserFunction · 0.70
MacrosFunction · 0.70

Tested by

no test coverage detected