TestSyntaxMatcher tests that patterns like "p." inside quoted strings are not incorrectly escaped by EscapeAssertion. This addresses the bug where matchers containing strings like "a.p.p.l.e" would have the ".p." pattern incorrectly replaced with "_p_".
(t *testing.T)
| 23 | // This addresses the bug where matchers containing strings like "a.p.p.l.e" |
| 24 | // would have the ".p." pattern incorrectly replaced with "_p_". |
| 25 | func TestSyntaxMatcher(t *testing.T) { |
| 26 | e, err := NewEnforcer("examples/syntax_matcher_model.conf") |
| 27 | if err != nil { |
| 28 | t.Fatalf("Error: %v\n", err) |
| 29 | } |
| 30 | // The matcher in syntax_matcher_model.conf is: m = r.sub == "a.p.p.l.e" |
| 31 | // This should match when r.sub is exactly "a.p.p.l.e" |
| 32 | testEnforce(t, e, "a.p.p.l.e", "file", "read", true) |
| 33 | testEnforce(t, e, "other", "file", "read", false) |
| 34 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…