logo       

RE: assertEquals("NaN", x, y, 0.0) where x=y=Double.NaN: msg#00158

java.junit.user

Subject: RE: assertEquals("NaN", x, y, 0.0) where x=y=Double.NaN

I get your point, Mark. I have been using a method similar to the
assertEqualsNaN(...) method you suggest. Although until now I've had it in
each testcase where it is needed. In an abstract super class would be
better.

Thanks.

Morten

> -----Original Message-----
> From: Mark Meyers [mailto:markm@xxxxxxxxxxxxxxxxxxx]
> Sent: 21 June 2002 14:52
> To: 'junit@xxxxxxxxxxxxxxx'
> Subject: RE: [junit] assertEquals("NaN", x, y, 0.0) where x=y=Double.NaN
>
>
>
>
> > -----Original Message-----
> > From: Morten Grum, PH-Consult [mailto:mg@xxxxxx]
> ...
> > Hi
> >
> > x and y are both simple double.
> >
> > Oughtn't assertEquals("x and y", x, y, 0.0) succeed when both
> > x and y are
> > Double.NaN?
> >
> > At the moment I'm having to make a situation specific assert
> > statement when
> > I expect y is Double.NaN.
> >
> > I'm having to write ...
> > assertTrue("When y is NaN", Double.isNaN(y));
> >
> > I know java returns false on (Double.NaN==y) even when y is
> > Double.NaN, but
> > for our assert statements I'd say it'd be more practical/general if
> > assertEquals succeeded when both were NaN.
> >
> ...
> They are correct, in that f0(x)=(5.0-x)/(5.0-x) and
> f1(x)=(5.0-x)*(5.0-x)/(5.0-x) are not equal for
> x = 5.O, and both are indeterminated (NaN). If you would change
> assertEquals(double, double, double)
> errors could be introduced for other users.
>
> Why not introduce a method (in an abstract super class perhaps);
> tailored to
> your specific needs ?
> assertEqualsNaN(double x, double y, double delta){
> if(Double.isNaN(x) && Double.isNaN(y)){
> assertTrue(true);
> }else{
> assertEquals(x, y, delta);
> }
> }
>
>
> To unsubscribe from this group, send an email to:
> junit-unsubscribe@xxxxxxxxxxxxxxx
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise