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

Function TestExpressionSizeCodePointLimit

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

Source from the content-addressed store, hash-verified

2303}
2304
2305func TestExpressionSizeCodePointLimit(t *testing.T) {
2306 p, err := NewParser(Macros(AllMacros...), ExpressionSizeCodePointLimit((2)))
2307 if err != nil {
2308 t.Fatal(err)
2309 }
2310 src := common.NewTextSource("foo")
2311 _, errs := p.Parse(src)
2312 if got, want := len(errs.GetErrors()), 1; got != want {
2313 t.Fatalf("got %d errors, want %d errors: %s", got, want, errs.ToDisplayString())
2314 }
2315 if got, want := errs.GetErrors()[0].Message, "expression code point size exceeds limit: size: 3, limit 2"; got != want {
2316 t.Fatalf("got %q, want %q: %s", got, want, errs.GetErrors()[0].ToDisplayString(src))
2317 }
2318}
2319
2320func TestParserOptionErrors(t *testing.T) {
2321 if _, err := NewParser(Macros(AllMacros...), MaxRecursionDepth(-2)); err == nil {

Callers

nothing calls this directly

Calls 7

ParseMethod · 0.95
NewTextSourceFunction · 0.92
GetErrorsMethod · 0.80
NewParserFunction · 0.70
MacrosFunction · 0.70
ToDisplayStringMethod · 0.45

Tested by

no test coverage detected