• Post Reply Bookmark Topic Watch Topic
  • New Topic

NaN numbers  RSS feed

 
Denis Yuzvyk
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have method that perform check on input.
Something like this:

with JUnit i need check this method:


My question is:
with what value replace NAN_NUMBER ?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Denis Yuzvyk:
...My question is:
with what value replace NAN_NUMBER ?

The square root of a negative number is a good example.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understood the question, then the easiest solution is to use to constant, Double.NaN. Also, I see that the comment says you need a MyException to be thrown, but your test is testing for any exception to be thrown. A more appropriate test would be:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!