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

Function TestExpressionSizeCodePointLimit

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

Source from the content-addressed store, hash-verified

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

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