Return-Path: X-Original-To: apmail-maven-dev-archive@www.apache.org Delivered-To: apmail-maven-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BC96049AC for ; Sun, 12 Jun 2011 19:52:42 +0000 (UTC) Received: (qmail 25831 invoked by uid 500); 12 Jun 2011 19:52:42 -0000 Delivered-To: apmail-maven-dev-archive@maven.apache.org Received: (qmail 25768 invoked by uid 500); 12 Jun 2011 19:52:42 -0000 Mailing-List: contact dev-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Developers List" Reply-To: "Maven Developers List" Delivered-To: mailing list dev@maven.apache.org Received: (qmail 25760 invoked by uid 99); 12 Jun 2011 19:52:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Jun 2011 19:52:42 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of stephen.alan.connolly@gmail.com designates 74.125.82.171 as permitted sender) Received: from [74.125.82.171] (HELO mail-wy0-f171.google.com) (74.125.82.171) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Jun 2011 19:52:35 +0000 Received: by wyb32 with SMTP id 32so3221218wyb.30 for ; Sun, 12 Jun 2011 12:52:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=OZdAkRj1LDn6ax7Q59a5bH1ZbMDDSY6Erx7QHtkPxuc=; b=ieVp5AORVnUHpILpnrsYfsmZyL+8Eq8sT5d2pEnb5VuJv5pnj8+DqUSAEiolBNkGXD wLkRViDVd+1Pat6NAx7krA2Ce8ALR2OTxKX18AdORLI+6GkfgzGJu2fchjB4WBECZ+Gf +hPj82L4WOXwUqyWbAgPyRAbWYBC6dLJiLZY8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=Vgj/BOe7q5nUqcCD7QrtjeoNCLL8cxT8DE6X8TkAG2qkXd9s1PCRdpbG2NNsHf1Ypu /7wSqRRxvvgWcYKUGEf8eEoRIxOIAONJp82x99IAoB1uefbuLOBjVypvwwwQbuVObeOH 20XAx/ZV1Tv+ySO4PXRnH0iaT4uvf6fDk98WY= MIME-Version: 1.0 Received: by 10.227.6.18 with SMTP id 18mr4515012wbx.66.1307908334364; Sun, 12 Jun 2011 12:52:14 -0700 (PDT) Received: by 10.227.9.163 with HTTP; Sun, 12 Jun 2011 12:52:14 -0700 (PDT) In-Reply-To: References: Date: Sun, 12 Jun 2011 20:52:14 +0100 Message-ID: Subject: Re: org.codehaus.plexus.util.CollectionUtils.intersection From: Stephen Connolly To: Maven Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable At the very leaset assertThat(actual, is(expected)); gives better diagnostics then there is assertThat(actual, not(is(unexpected)); nice ones are assertThat(actual, hasItems(expectedContents)); On 12 June 2011 20:43, Benson Margulies wrote: > Next class. I haven't learned that one yet. > > On Sun, Jun 12, 2011 at 3:39 PM, Stephen Connolly > wrote: >> On 12 June 2011 20:23, Benson Margulies wrote: >>> I think I've written a unit test for the contract of this function as >>> written in the javadoc, but it fails. The intersection function >>> returns an empty collection when the inputs most definitely have a >>> non-null intersection. What am I missing? >>> >>> =A0 =A0@SuppressWarnings( "rawtypes" ) >>> =A0 =A0@Test >>> =A0 =A0public void testIntersection() throws Exception { >>> =A0 =A0 =A0 =A0Collection c1 =3D new ArrayList(); >>> =A0 =A0 =A0 =A0Collection c2 =3D new ArrayList(); >>> =A0 =A0 =A0 =A0/* >>> =A0 =A0 =A0 =A0 * An exhaustive black box test here >>> =A0 =A0 =A0 =A0 * would involve generating a great deal of data, >>> =A0 =A0 =A0 =A0 * perhaps even different sizes and collection classes. >>> =A0 =A0 =A0 =A0 */ >>> >>> =A0 =A0 =A0 =A0c1.add("red"); >>> =A0 =A0 =A0 =A0c1.add("blue"); >>> =A0 =A0 =A0 =A0c1.add("green"); >>> =A0 =A0 =A0 =A0c1.add("socialist"); >>> =A0 =A0 =A0 =A0c1.add("red"); >>> =A0 =A0 =A0 =A0c1.add("purple"); >>> =A0 =A0 =A0 =A0c1.add("porpoise"); >>> =A0 =A0 =A0 =A0c1.add("green"); >>> =A0 =A0 =A0 =A0c1.add("blue"); >>> =A0 =A0 =A0 =A0c1.add("gray"); >>> >>> =A0 =A0 =A0 =A0c1.add("blue"); >>> =A0 =A0 =A0 =A0c1.add("12"); >>> =A0 =A0 =A0 =A0c1.add("15"); >>> =A0 =A0 =A0 =A0c1.add("blue"); >>> =A0 =A0 =A0 =A0c1.add("porpoise"); >>> =A0 =A0 =A0 =A0c1.add("33.3"); >>> =A0 =A0 =A0 =A0c1.add("jabberwock"); >>> >>> =A0 =A0 =A0 =A0Multiset correct =3D HashMultiset.create(); >>> =A0 =A0 =A0 =A0correct.add( "blue" ); >>> =A0 =A0 =A0 =A0correct.add( "blue" ); >>> =A0 =A0 =A0 =A0correct.add( " porpoise "); >>> >>> =A0 =A0 =A0 =A0@SuppressWarnings( "unchecked" ) >>> =A0 =A0 =A0 =A0Collection res =3D CollectionUtils.intersection(= c1, c2 ); >>> =A0 =A0 =A0 =A0Multiset actual =3D HashMultiset.create(); >>> =A0 =A0 =A0 =A0actual.addAll(res); >>> =A0 =A0 =A0 =A0assertEquals( correct, actual ); >> >> I hate the bog standard assertEquals on collections... if you'd used >> the new style assertThat( actual, ... ) with the appropriate matcher >> you'd have better debug info ;-) >> >>> >>> =A0 =A0} >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org >>> For additional commands, e-mail: dev-help@maven.apache.org >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org >> For additional commands, e-mail: dev-help@maven.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org > For additional commands, e-mail: dev-help@maven.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For additional commands, e-mail: dev-help@maven.apache.org