[OKC JUG] A better way to do this?
Ryan Hoegg
ryan.hoegg at gmail.com
Thu Aug 13 13:29:22 PDT 2009
Hello,
I recently wanted to assert that two collections were equivalent. Here's
what I ended up writing. Is there a better way to implement this, or
something in junit I missed?
private <T extends Collection<?>> void assertSetEquivalence(T expected,
T actual)
{
assertEquals("different number of elements", expected.size(),
actual.size());
assertTrue("some expected elements were missing",
expected.containsAll(actual));
assertTrue("some unexpected elements were included",
actual.containsAll(expected));
}
Anyone?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okcjug.org/pipermail/jug-okcjug.org/attachments/20090813/b7e147f4/attachment.htm>
More information about the Jug
mailing list