From: Eric B. R. <eb...@tc...> - 2003-03-28 15:33:38
|
On Friday, March 28, 2003, at 10:28 AM, kea...@na... =20= wrote: > I guess I was just lazy.=A0 There aren't any existing tests for the =20= > MathTool AFAICT.=A0 > > I don't know exactly how to do a test case for random() -- since we =20= > obviously don't know what the expected result is.=A0 I suppose I could = =20 > loop a bunch of times and make sure that all values returned are in =20= > range and that all values in the range get returned, or I could just =20= > compute the min/max/mean and check them.=A0 But this seems like = overkill =20 > for such a simple (one-line) method.=A0 http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/webmacro/webmacro/test/=20= unit/org/webmacro/util/TestMathTool.java?rev=3D1.2&content-type=3Dtext/=20= vnd.viewcvs-markup it's been there since Nov. 2002 and does basically what you describe =20 above. eric > > The main method I added allows you to do a quick visual check that the = =20 > thing is working.=A0 This is better than what we had before. > > Keats > > > -----Original Message----- > > From: Lane Sharman [mailto:la...@op...] > > Sent: Friday, March 28, 2003 10:22 AM > > To: Keats Kirsch > > Cc: web...@li...; jim...@ag...; > > EricB. Ridge > > Subject: Re: [Webmacro-devel] MathTool.random broken? > > > > > > Why did you not add a test case? > > > > -Lane > > > > Keats Kirsch wrote: > > > > > I've committed this change along with a little test in main(). > > > > > > Keats > > > > > > Eric B. Ridge wrote: > > > > > >> On Thursday, March 27, 2003, at 11:29=A0 AM, > > kea...@na... > > >> wrote: > > >> > > >> > > I may fail to understand the code, but it seems wrong to me > > >> > > so I changed it to > > >> > > > > >> > > public static final int random(int start, int end) { > > >> > >=A0=A0=A0=A0=A0=A0 int iRet =3D start + (int) ((end - start + > > >> > > 1)*java.lang.Math.random()); > > >> > >=A0=A0=A0=A0=A0=A0 return iRet > end ? end : iRet; > > >> > > } > > >> > > > >> > Your code looks right to me, but the final test is > > unnecessary, since > > >> > Math.random() is always less than 1.0. > > >> > > > >> > Eric, I think this was your thing.=A0 Do you want to do the = fix, =20 > or > > >> > shall I? > > >> > > >> If you're in the mood, go ahead.=A0 :)=A0 I'm snowed under here = at the > > >> office. > > >> > > >> eric > > >> > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by: > > > The Definitive IT and Networking Event. Be There! > > > NetWorld+Interop Las Vegas 2003 -- Register today! > > > http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en > > > _______________________________________________ > > > Webmacro-devel mailing list > > > Web...@li... > > > https://lists.sourceforge.net/lists/listinfo/webmacro-devel > > > > > > > -- > > Lane Sharman > > Learn About Conga, All Java GUI Builder: http://opendoors.com/conga > > Java Software Portal: http://opendoors.com > > > > > > > > > |