Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!border3.nntp.ams.giganews.com!backlog3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 10 Aug 2014 11:42:00 -0500 Date: Sun, 10 Aug 2014 17:41:55 +0100 From: lipska the kat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: in1To10, a simple test plan References: <0c8de66a-429a-4697-b575-35f37a7b6882@googlegroups.com> <0rqdnVpuJ9ayDnrOnZ2dnUVZ8sKdnZ2d@bt.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <7t6dndde4a1FPXrOnZ2dnUVZ7o2dnZ2d@bt.com> Lines: 55 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-kviJawino42AA3vyJgBHOIe/sfqtYctU2dUYnuhi0wnUjF2u6k/5c5ri4HtCDIPtdlOXST19HPFy8Y/!cgXUCdJUD5fIStoYTJI8PGAUcOLAl5JB2XpJBScCMRIjQEJZmOenQNquNM8VJqh3L/ebHNlzER0= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 3888 Xref: csiph.com comp.lang.java.programmer:29633 On 10/08/14 17:01, Eric Sosman wrote: > On 8/10/2014 11:43 AM, lipska the kat wrote: >> [...] >> public class In1To10 { >> >> static boolean in1To10(int n, boolean outsideMode){ >> if(n == 1 || n == 10){ >> return true; >> } >> else{ >> return (n > 1 && n < 10) ^ outsideMode; >> } >> } >> >> public static void main(String[] args){ >> boolean outsideMode = true; >> //Expected: Actual: >> System.out.println(in1To10(1, outsideMode)); //true true >> System.out.println(in1To10(1, !outsideMode)); //true true >> System.out.println(in1To10(10, outsideMode)); //true true >> System.out.println(in1To10(10, !outsideMode)); //true true >> System.out.println(in1To10(0, outsideMode)); //true true >> System.out.println(in1To10(0, !outsideMode)); //false false >> System.out .println(in1To10(-1, outsideMode)); //true true >> System.out.println(in1To10(-1, !outsideMode)); //false false >> System.out.println(in1To10(2, outsideMode)); //false false >> System.out.println(in1To10(2, !outsideMode)); //true true >> System.out.println(in1To10(5, outsideMode)); //false false >> System.out.println(in1To10(5, !outsideMode)); //true true >> System.out.println(in1To10(9, outsideMode)); //false false >> System.out.println(in1To10(9, !outsideMode)); //true true >> System.out.println(in1To10(11, outsideMode)); //true true >> System.out.println(in1To10(11, !outsideMode)); //false false >> //etc >> } >> } > > While the notion of having a test plan is an excellent one, relying > on human eyeballs to verify the expected output is tedious and may be > error-prone. I'd suggest writing a helper method, something like I agree, in the real world of course we would probably use a test framework, something like JUnit perhaps as part of our 'agile' development process ... I was big into agile for a while, pair programming, client representatives, write the test before the code etc whatever happened to agile, is it still 'in favour'? Retirement can be a bitch, the garden needs attention NOW, so I'll have to leave reading that paper on process until later etc etc. -- lipska the kat - treacherous feline. Proudly nominated for IPOTY 2014 - LIGAF GNU/Linux user #560883 - linuxcounter.net