(t *testing.T)
| 2904 | } |
| 2905 | |
| 2906 | func 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 | |
| 2925 | func TestMaxExpressionNodeCount(t *testing.T) { |
| 2926 | for _, pratt := range []bool{false, true} { |
nothing calls this directly
no test coverage detected