-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Added ElementsAre and UnorderedElementsAre #2377
Conversation
Codecov Report
@@ Coverage Diff @@
## devel #2377 +/- ##
==========================================
+ Coverage 91.15% 91.19% +0.05%
==========================================
Files 187 188 +1
Lines 7691 7719 +28
==========================================
+ Hits 7010 7039 +29
+ Misses 681 680 -1 |
CHECK_THAT( vector_a, | ||
UnorderedElementsAre( array_a_plus_1, close_enough ) ); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also have (and support) rangeish types that don't have member begin (e.g. they provide ADL-findable begin only), and have different types for begin and end (the support for these is currently spotty, but the goal is to provide it eventually).
Honestly the test utils for this could use some refactoring and cleanup in general, so I don't blame you if you don't want to write the tests, but the impl should reasonably support these.
} | ||
|
||
} // namespace Matchers | ||
namespace Matchers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
huh, is this actually the formatting given by clang-format?
I would swear the clang-format had nested namespace indents disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems not: NamespaceIndentation: All
is specified (should be None
for zero indent) :
Line 16 in 61d0f7a
NamespaceIndentation: All |
I didn't check the code in too much detail, but here is a big note on this:
I want these to support matcher inputs on the expected side, so something like this can be written: Alternatively, I am willing to hear an argument on why the functionality above should have a different name (or, the functionality in this PR could be renamed to something like |
Thank you for the careful review!
OK, so just to check, the difference is then that
And
Makes sense to me, though I'll have to have a think about how to do it! If I can indeed do such a variadic matcher syntax, then it feel like |
Oh don't worry, that will come later. 🙃 And you are correct about the differences between I do think you might be underestimating the complexity to support both direct-element comparison, and matcher-based comparison. For the latter, most work can be reused from the support code in |
Probably! But worth a try! I don't mind to split to the work to
Then having separate names for each would be a shame and a bit confusing since they're so similar. Would it make sense to use an initializer-list constructor like std::vector: |
I'm still trying to think of how to do this, but it probably will take me a while to figure it out (I also will never complain if someone wants to Just Do It and preempt it, I claim no dibs!). Maybe it makes more sense to tidy and move to merge what exists here? This interface remains the same?:
|
9080853
to
ae08274
Compare
[This is a continuations of the solid start made in #2133 by @Garz4 in 2020, with some modifications]
Added
ElementsAre
andUnorderedElementsAre
generic range matchers which take a range during construction and their match method take a range as well.Addresses issue #2087
As before, no matcher constructor analogous to
ContainsMatcherMatcher
is provided, as this is just the same asAllMatch
.Differences to the previous PR:
std::equal_to