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

Function TestExpressionSizeCodePointLimit

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

Source from the content-addressed store, hash-verified

2904}
2905
2906func TestExpressionSizeCodePointLimit(t *testing.T) {
2907 for _, pratt := range []bool{false, true} {
2908 t.Run(fmt.Sprintf("enablePrattParser=%t", pratt), func(t *testing.T) {
2909 p, err := NewParser(Macros(AllMacros...), ExpressionSizeCodePointLimit(2), EnablePrattParser(pratt))
2910 if err != nil {
2911 t.Fatal(err)
2912 }
2913 src := common.NewTextSource("foo")
2914 _, errs := p.Parse(src)
2915 if got, want := len(errs.GetErrors()), 1; got != want {
2916 t.Fatalf("got %d errors, want %d errors: %s", got, want, errs.ToDisplayString())
2917 }
2918 if got, want := errs.GetErrors()[0].Message, "expression code point size exceeds limit: size: 3, limit 2"; got != want {
2919 t.Fatalf("got %q, want %q: %s", got, want, errs.GetErrors()[0].ToDisplayString(src))
2920 }
2921 })
2922 }
2923}
2924
2925func TestMaxExpressionNodeCount(t *testing.T) {
2926 for _, pratt := range []bool{false, true} {

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected