Skip to content

Conversation

@pajlada
Copy link
Contributor

@pajlada pajlada commented Mar 27, 2022

This allows users to have full control over the regular expression used for matching.

My use-case was matching a multiline string pattern, and the way MatchString was used in the match-function made that infeasible.

With this change, I was able to use the Matches matcher like this:

c.Assert("asd\nasd", qt.Matches, regexp.MustCompile(`asd.*`))

Happy to update naming of variables on request.
I left naming of parameters/arguments on purpose to keep the diff minimal, but happy to change that too.

As an alternative, if this change is not acceptable, I know I could implement my own Checker handles regular expressions like this, so no worries if this change does not fit into the project!

Copy link
Owner

@frankban frankban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an interesting feature.
If you want, please go ahead!

@pajlada
Copy link
Contributor Author

pajlada commented Sep 18, 2022

@frankban I've gone ahead and pushed missing tests for this functionality to maintain the 100% test coverage of checker.go, let me know if you prefer this to be rebased or something before being approved/merged in 🙂

Copy link
Owner

@frankban frankban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good!
Could you please add:

  • similar tests for ErrorMatches and PanicMatches;
  • updated docs for the 3 involved checkers.
    Thanks!
@pajlada
Copy link
Contributor Author

pajlada commented Sep 24, 2022

I added the following tests:
qt.ErrorMatches single-line match expectedNegateFailure
qt.ErrorMatches multi-line match expectedNegateFailure
qt.ErrorMatches multi-line match expectedCheckFailure
qt.PanicMatches single-line match expectedNegateFailure
qt.PanicMatches multi-line match expectedNegateFailure
qt.PanicMatches multi-line match expectedCheckFailure

I added the following documentation:
Added example for Matches checker in checker.go and in README.md
Added example for ErrorMatches checker in checker.go and in README.md
Added example for PanicMatches checker in checker.go and in README.md

@pajlada pajlada requested a review from frankban September 24, 2022 16:27
…exp.Regexp

This allows users to have full control over the pattern used for
matching, and all of its flags (multiline)
 - qt.ErrorMatches single-line match `expectedNegateFailure`
 - qt.ErrorMatches multi-line match `expectedNegateFailure`
 - qt.ErrorMatches multi-line match `expectedCheckFailure`
 - qt.PanicMatches single-line match `expectedNegateFailure`
 - qt.PanicMatches multi-line match `expectedNegateFailure`
 - qt.PanicMatches multi-line match `expectedCheckFailure`
@pajlada pajlada force-pushed the feat/checker-accept-regexp branch from 6403f3a to b3b1f6c Compare November 22, 2022 16:07
…atches

Documentation added both to the checker.go file and the README.md file
@pajlada pajlada force-pushed the feat/checker-accept-regexp branch from b3b1f6c to 08f7639 Compare November 22, 2022 16:19
@frankban frankban merged commit 1af932f into frankban:master Apr 11, 2023
@pajlada pajlada deleted the feat/checker-accept-regexp branch April 11, 2023 21:52
@frankban
Copy link
Owner

Released as v1.14.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants