-
Notifications
You must be signed in to change notification settings - Fork 377
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
Map entry matchers #123
Map entry matchers #123
Conversation
…p with a convenience factory method which takes a variable number of matchers for individual map entries
I can't get this to merge javadoc is broken because it doesn't recognise @deprecated, rather than @deprecated. Please fix. |
@sf105 Is that comment meant for this PR? I'm on my phone so can't be sure, but I don't think there's any @deprecated, of any capitalisation, in this PR. |
You branched from an old version of hamcrest that doesn't build in Java 8 any more. I might just branch again and fix it. S
|
Got it. I'll jump on this at the weekend, when I'm back in front of a computer. |
Okay, so:
So whilst the problems on the v2.0.0.0 branch are not of my making, the problem that my branch is built on that branch is! It seems like the best thing would be to merge v2.0.0.0 into master, as you have done in the past; however, i'm not sure i know enough about the changes in either branch to do that properly. Alternatively, i could cherry-pick my changes onto master, and submit a new PR. Or i could just leave it to you. What would you like me to do? |
This has now become #160. |
This adds two complementary matchers for working with maps.
The main matcher is
IsMapWithEntries
, which is just aFeatureMatcher
for Map::entrySet. This is essentially an escape hatch from the world of maps to the world of true collections; it allows a user to write matches on maps in terms of their set of entries, using the rich set of matchers available for collections (principallycontains
and friends).The second matcher is
IsMapEntry
, which makes it easy to write matches on the map entries themselves.I end up writing these two matchers, in some form, in most projects i work on, because this approach so useful. Specifically, i think it's much more useful to be able to view maps as collections than it is to have a range of matchers specifically for maps.
It's possible i'm simply insane, and nobody else will find these useful. But just in case they do, here they are!