...
Code Block |
---|
language | bash |
---|
title | Result of the assertion: EXPECT_NEAR(get_pi(), 3.14159265, 1e-9) |
---|
linenumbers | true |
---|
|
The difference between get_pi() and 3.14159265 is 3.5897929073769319e-09, which exceeds 1e-9, where
get_pi() evaluates to 3.1415926535897931,
3.14159265 evaluates to 3.1415926500000002, and
1e-9 evaluates to 1.0000000000000001e-09.
[ FAILED ] GetPiOperation.AbsoluteError (0 ms) |
The second way is to simply place two comparison value assertions as shown below:
Code Block |
---|
language | cpp |
---|
title | TEST(GetPiOperation, InRange) |
---|
linenumbers | true |
---|
|
TEST(GetPiOperation, InRange) {
EXPECT_LE(get_pi(), 3.1416);
EXPECT_GE(get_pi(), 3.1415);
} |
3. Testing boundary conditions
...