www.digitalmars.com         C & C++   DMDScript  

D - math2 unittest

reply "Sean L. Palmer" <seanpalmer earthlink.net> writes:
Just noticed that the unittest for sign(extended) in math2.d is wrong (it's
testing long, not extended form)

int sign(extended n)
{
 return (n > 0 ? +1 : (n < 0 ? -1 : 0));
}

unittest
{
 assert(sign(0.0L) == 0);
 assert(sign(+123.456L) == +1);
 assert(sign(-123.456L) == -1);
}
Jun 15 2002
parent reply Pavel Minayev <evilone omen.ru> writes:
On Sat, 15 Jun 2002 14:31:33 -0700 "Sean L. Palmer" <seanpalmer earthlink.net> 
wrote:

 Just noticed that the unittest for sign(extended) in math2.d is wrong (it's
 testing long, not extended form)

sign() is overloaded; you've missed declarations for int sign(int) and int sign(long). =)
Jun 16 2002
parent reply "Sean L. Palmer" <seanpalmer earthlink.net> writes:
There are 2 unit tests that test sign(long)

Sean

"Pavel Minayev" <evilone omen.ru> wrote in message
news:CFN374234902009954 news.digitalmars.com...
 On Sat, 15 Jun 2002 14:31:33 -0700 "Sean L. Palmer"

 wrote:

 Just noticed that the unittest for sign(extended) in math2.d is wrong


 testing long, not extended form)

sign() is overloaded; you've missed declarations for int sign(int) and int sign(long). =)

Jun 16 2002
parent reply Pavel Minayev <evilone omen.ru> writes:
On Sun, 16 Jun 2002 03:44:48 -0700 "Sean L. Palmer" <seanpalmer earthlink.net> 
wrote:

 There are 2 unit tests that test sign(long)

Well, actually, appending an L at the end of a float constant makes it extended - so 123.456L is an extended value, and it was sign(extended) version that was tested.
Jun 16 2002
parent "Sean L. Palmer" <seanpalmer earthlink.net> writes:
DOH

Not used to that yet.  Must have overlooked the decimal.

Of course you are correct.

Sean

"Pavel Minayev" <evilone omen.ru> wrote in message
news:CFN374236174609143 news.digitalmars.com...
 On Sun, 16 Jun 2002 03:44:48 -0700 "Sean L. Palmer"

 wrote:

 There are 2 unit tests that test sign(long)

Well, actually, appending an L at the end of a float constant makes it extended - so 123.456L is an extended value, and it was sign(extended) version that was tested.

Jun 16 2002