miracle-wm/tests/window_tree_test.cpp
Matthew Kosarek bc0746c574 feature: unit testing integration + bugfix for starting in fullscreen mode (#13)
* cleanup: node interface

* bugfix: starting in fullscreen no longer breaks us

* feature: unit testing integration

* bad actions
2024-01-15 10:56:41 -05:00

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));
}