Closed jmburges closed 9 years ago
I like this idea, but I feel like the current implementation is lossy:
expect(@[@1,@1,@2]).to.equalInAnyOrder(@[@1,@2]);
Would end up passing here, but they are not the same arrays, in a different order. Perhaps the implementation could order them both by description, then loop through one array and check if the other arrays item is the same?
Also, CHANGELOG please :)
Perhaps the implementation could order them both by description, then loop through one array and check if the other arrays item is the same?
NSCountedSet
should do the trick here
Thanks for the pull request! :sparkling_heart:
However, I'm not sure I think this is worth adding to expecta. It seems that if you frequently need to compare two arrays independent of order, using an NSArray
is the actual problem.
@robb Thanks for doing so much else! :sparkles:
I end up using this a ton for times where I want to ensure the same exact keys in an NSDictionary
and allKeys
returns an NSArray
.
I 100% see your point, if you don't care about ordering stop using an NSArray
. Up to you really :) If we don't include it in expecta, I'll just make a cocoapod.
Yeah, I think I'm onboard with the having as an extension, it could fit quite well in Expecta-Comparison or it could be it's own independent thing.
There are a bunch of Gists and blogs on this, but I find myself doing
beSupersetOf
andhasCountOf
together all the time to get the same effect. Figured I would submit this back in.Converts the NSArrays to NSSets and compares them so that order doesn't matter.
First PR to Expecta so feedback welcome!!