Created
January 31, 2018 17:13
Revisions
-
lithiumhead created this gist
Jan 31, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #include <iostream> #include <math.h> #include <gtest/gtest.h> double squareroot (double a) { if(a<0) return -1; else return sqrt(a); }; TEST (SquareRootTest, PositiveNos) { EXPECT_EQ (18.0, squareroot (324.0)); EXPECT_EQ (25.4, squareroot (645.16)); EXPECT_EQ (50.332, 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(); }