diff options
Diffstat (limited to 'gtest')
| -rw-r--r-- | gtest/testgtest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/gtest/testgtest.cpp b/gtest/testgtest.cpp new file mode 100644 index 0000000..bca9594 --- /dev/null +++ b/gtest/testgtest.cpp @@ -0,0 +1,22 @@ +#include "gtest/gtest.h" +#include "math.h" + +double squareroot(double input){ + return pow(input,0.5); +} + +TEST(SquareRootTest, PositiveNos) { + EXPECT_EQ (18.0, squareroot(324.0)); + EXPECT_EQ (25.4, squareroot(645.16)); + EXPECT_EQ (50.3321, squareroot(2533.310224)); +} + +TEST (SquareRootTest, ZeroAndNegativeNos) { + ASSERT_EQ (0.0, squareroot (0.0)); + ASSERT_EQ (-1, squareroot(-22.0)); +} + +int main(int argc, char **argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}
\ No newline at end of file |
