Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check.Matches doesn’t handle regular expressions with alternatives correctly #66

Open
rillig opened this issue Nov 21, 2015 · 0 comments

Comments

@rillig
Copy link

rillig commented Nov 21, 2015

func (s *Suite) TestMatch(c *check.C) {
    re := `foo|bar`

    c.Check("foo", check.Matches, re)
    c.Check("football", check.Matches, re) // Should not match
    c.Check("ballfoot", check.Not(check.Matches), re)
}

The problem is this line in checkers.go:

matches, err := regexp.MatchString("^"+reStr+"$", valueStr)

It should be:

matches, err := regexp.MatchString("^(?:"+reStr+")$", valueStr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant