mirror of
https://github.com/miracle-wm-org/miracle-wm.git
synced 2024-11-30 02:09:10 +03:00
bc0746c574
* cleanup: node interface * bugfix: starting in fullscreen no longer breaks us * feature: unit testing integration * bad actions
26 lines
497 B
C++
26 lines
497 B
C++
#include <gtest/gtest.h>
|
|
#include <math.h>
|
|
|
|
double squareRoot(const double a)
|
|
{
|
|
double b = sqrt(a);
|
|
if(b != b) // NaN check
|
|
{ return -1.0; }
|
|
else
|
|
{ return sqrt(a); }
|
|
}
|
|
|
|
TEST(SquareRootTest, PositiveNos)
|
|
{
|
|
ASSERT_EQ(6, squareRoot(36.0));
|
|
ASSERT_EQ(18.0, squareRoot(324.0));
|
|
ASSERT_EQ(25.4, squareRoot(645.16));
|
|
ASSERT_EQ(0, squareRoot(0.0));
|
|
}
|
|
|
|
TEST(SquareRootTest, NegativeNos)
|
|
{
|
|
ASSERT_EQ(-1.0, squareRoot(-15.0));
|
|
ASSERT_EQ(-1.0, squareRoot(-0.2));
|
|
}
|