Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
titleResult of the assertion: EXPECT_NEAR(get_pi(), 3.14159265, 1e-9)
linenumberstrue
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
languagecpp
titleTEST(GetPiOperation, InRange)
linenumberstrue
TEST(GetPiOperation, InRange) {
    EXPECT_LE(get_pi(), 3.1416);
    EXPECT_GE(get_pi(), 3.1415);
}

3. Testing boundary conditions

...