blob: bca95943e7aca34743f8a55345efe6579d4b29b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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();
}
|