From harmony-dev-return-11292-apmail-incubator-harmony-dev-archive=incubator.apache.org@incubator.apache.org Wed Aug 02 08:37:03 2006 Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 88023 invoked from network); 2 Aug 2006 08:36:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Aug 2006 08:36:57 -0000 Received: (qmail 57091 invoked by uid 500); 2 Aug 2006 08:36:49 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 57048 invoked by uid 500); 2 Aug 2006 08:36:49 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 57012 invoked by uid 99); 2 Aug 2006 08:36:49 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2006 01:36:49 -0700 X-ASF-Spam-Status: No, hits=1.9 required=10.0 tests=DNS_FROM_RFC_ABUSE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: 202.81.18.154 is neither permitted nor denied by domain of smallsmallorgan@gmail.com) Received: from [202.81.18.154] (HELO ausmtp05.au.ibm.com) (202.81.18.154) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Aug 2006 01:36:47 -0700 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp05.au.ibm.com (8.13.6/8.13.6) with ESMTP id k728d61L7458892 for ; Wed, 2 Aug 2006 18:39:06 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.250.242]) by sd0208e0.au.ibm.com (8.13.6/8.13.6/NCO v8.1) with ESMTP id k728dHGJ219150 for ; Wed, 2 Aug 2006 18:39:33 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id k728ZgFE020290 for ; Wed, 2 Aug 2006 18:35:42 +1000 Received: from d23m0011.cn.ibm.com ([9.181.32.74]) by d23av01.au.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k728ZMM4017991 for ; Wed, 2 Aug 2006 18:35:41 +1000 Received: from [127.0.0.1] ([9.181.106.176]) by d23m0011.cn.ibm.com (Lotus Domino Release 6.5.5HF262) with ESMTP id 2006080216353481-21041 ; Wed, 2 Aug 2006 16:35:34 +0800 Message-ID: <44D063BE.8080909@gmail.com> Date: Wed, 02 Aug 2006 16:35:10 +0800 From: Spark Shen User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: harmony-dev@incubator.apache.org Subject: Re: [classlib][luni] Is fully comply with Comparator.compare(T, T) necessary (Re JIRA harmony 1026) References: <44D0499A.6050601@gmail.com> <44D04E99.8020509@gmail.com> <44D0525F.50006@gmail.com> <6e47b64f0608020056r4cc04151g525053b4db0c03ae@mail.gmail.com> In-Reply-To: <6e47b64f0608020056r4cc04151g525053b4db0c03ae@mail.gmail.com> X-MIMETrack: Itemize by SMTP Server on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 02/08/2006 16:35:34, Serialize by Router on D23M0011/23/M/IBM(Release 6.5.5HF262 | April 5, 2006) at 02/08/2006 16:35:41, Serialize complete at 02/08/2006 16:35:41 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-2022-JP X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Stepan Mishura 写道: > On 8/2/06, Spark Shen wrote: >> >> Richard Liang 写道: >> > >> > >> > Spark Shen wrote: >> >> I constructed a MockComparator as below: >> >> public static class MockComparator implements Comparator { >> >> public int compare(T o1, T o2) { >> >> if(null == o1) return -1; >> >> if(o1.equals(o2)) { >> >> return 0; >> >> } >> >> return 1; >> >> } >> >> } >> >> >> >> This comparator regards null as the smallest object and TreeMap uses >> >> this Comparator as a null-tolerable comparator. >> >> And this comparator is used to test the behavior of TreeMap.headMap() >> >> when the input is null. >> >> >> >> Since null is recognized as smallest, the expected length of the >> >> returned SortedMap of TreeMap.headMap(null) will be zero. >> >> >> >> My point here is that, under this situation, the MockComparator does >> >> not care about the order of non-null objects, it just know >> >> null is always smaller. So, is it acceptable that - in this >> >> comparator, compare method does not judge the order of all the >> >> non-null objects? >> >> (does not comply with doc of comparator.compare) >> >> >> > What will happen when both o1 and o2 are null? >> When both are null, -1 will be returned. This mocked comparator is used >> as a boundary test condition, and under this condition, >> if there is null entry contained in tree map, is will not be included in >> the SortedMap returned by headMap(null) method. > > > In other words, you don't expect that in your testcase the mock > comparator > will compare 'null's. Right? No,it does not. This comparator is used to test the condition that once null is used as the head element, then no other elements can be contained in the returned SortedMap, even if the other element is null. So, to the extreme, I construct the mocked comparator like that. Best regards > > Thanks, > Stepan. > > Best regards, >> >> > >> > My understanding about mocked objects is that: we could only implement >> > some necessary logic, but the logic must be compliant with the >> > specification. Correct me if I'm wrong. Thanks a lot. >> > >> > Best regards, >> > Richard >> >> Best regards >> >> >> > >> >> >> -- >> Spark Shen >> China Software Development Lab, IBM >> >> >> >> --------------------------------------------------------------------- >> Terms of use : http://incubator.apache.org/harmony/mailing.html >> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org >> For additional commands, e-mail: harmony-dev-help@incubator.apache.org >> >> > > -- Spark Shen China Software Development Lab, IBM --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org For additional commands, e-mail: harmony-dev-help@incubator.apache.org