When a test fails an expectation, the framework marks the test as a failure and then continues executing the test. They’re useful when you want to verify multiple dimensions of the same feature and see all the errors at the same time.
|
#define | EXPECT_TRUE(expr) _PW_TEST_EXPECT(_PW_TEST_BOOL(expr, true)) |
|
#define | EXPECT_FALSE(expr) _PW_TEST_EXPECT(_PW_TEST_BOOL(expr, false)) |
|
#define | EXPECT_EQ(lhs, rhs) _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, ==)) |
|
#define | EXPECT_NE(lhs, rhs) _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, !=)) |
|
#define | EXPECT_GT(lhs, rhs) _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, >)) |
|
#define | EXPECT_GE(lhs, rhs) _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, >=)) |
|
#define | EXPECT_LT(lhs, rhs) _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, <)) |
|
#define | EXPECT_LE(lhs, rhs) _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, <=)) |
|
#define | EXPECT_NEAR(lhs, rhs, epsilon) _PW_TEST_EXPECT(_PW_TEST_NEAR(lhs, rhs, epsilon)) |
|
#define | EXPECT_FLOAT_EQ(lhs, rhs) |
|
#define | EXPECT_DOUBLE_EQ(lhs, rhs) |
|
#define | EXPECT_STREQ(lhs, rhs) _PW_TEST_EXPECT(_PW_TEST_C_STR(lhs, rhs, ==)) |
|
#define | EXPECT_STRNE(lhs, rhs) _PW_TEST_EXPECT(_PW_TEST_C_STR(lhs, rhs, !=)) |
|
#define | PW_TEST_EXPECT_OK(expr) |
|
◆ EXPECT_DOUBLE_EQ
#define EXPECT_DOUBLE_EQ |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| |
Value: _PW_TEST_EXPECT( \
_PW_TEST_NEAR(lhs, rhs, 4 * std::numeric_limits<double>::epsilon()))
Verifies that the two double values rhs
and lhs
are approximately equal, to within 4 units in the last place (ULPs) from each other.
- Parameters
-
[in] | lhs | The left side of the equality comparison. |
[in] | rhs | The right side of the equality comparison. |
◆ EXPECT_EQ
#define EXPECT_EQ |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, ==)) |
Verifies that lhs == rhs
.
Does pointer equality on pointers. If used on two C strings, EXPECT_EQ
tests if they are in the same memory location, not if they have the same value. Use EXPECT_STREQ
to compare C strings (e.g. const char*
) by value.
When comparing a pointer to NULL
use EXPECT_EQ(ptr, nullptr)
instead of EXPECT_EQ(ptr, NULL)
.
- Parameters
-
[in] | lhs | The left side of the equality comparison. |
[in] | rhs | The right side of the equality comparison. |
◆ EXPECT_FALSE
#define EXPECT_FALSE |
( |
|
expr | ) |
_PW_TEST_EXPECT(_PW_TEST_BOOL(expr, false)) |
Verifies that expr
evaluates to false.
- Parameters
-
[in] | expr | The expression to evaluate. |
◆ EXPECT_FLOAT_EQ
#define EXPECT_FLOAT_EQ |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| |
Value: _PW_TEST_EXPECT( \
_PW_TEST_NEAR(lhs, rhs, 4 * std::numeric_limits<float>::epsilon()))
Verifies that the two float values rhs
and lhs
are approximately equal, to within 4 units in the last place (ULPs) from each other.
- Parameters
-
[in] | lhs | The left side of the equality comparison. |
[in] | rhs | The right side of the equality comparison. |
◆ EXPECT_GE
#define EXPECT_GE |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, >=)) |
Verifies that lhs >= rhs
.
- Parameters
-
[in] | lhs | The left side of the comparison. |
[in] | rhs | The right side of the comparison. |
◆ EXPECT_GT
#define EXPECT_GT |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, >)) |
Verifies that lhs > rhs
.
- Parameters
-
[in] | lhs | The left side of the comparison. |
[in] | rhs | The right side of the comparison. |
◆ EXPECT_LE
#define EXPECT_LE |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, <=)) |
Verifies that lhs <= rhs
.
- Parameters
-
[in] | lhs | The left side of the comparison. |
[in] | rhs | The right side of the comparison. |
◆ EXPECT_LT
#define EXPECT_LT |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, <)) |
Verifies that lhs < rhs
.
- Parameters
-
[in] | lhs | The left side of the comparison. |
[in] | rhs | The right side of the comparison. |
◆ EXPECT_NE
#define EXPECT_NE |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| _PW_TEST_EXPECT(_PW_TEST_OP(lhs, rhs, !=)) |
Verifies that lhs != rhs
.
Does pointer equality on pointers. If used on two C strings, it tests if they are in different memory locations, not if they have different values. Use EXPECT_STRNE
to compare C strings (e.g. const char*
) by value.
When comparing a pointer to NULL
, use EXPECT_NE(ptr, nullptr)
instead of EXPECT_NE(ptr, NULL)
.
- Parameters
-
[in] | lhs | The left side of the inequality comparison. |
[in] | rhs | The right side of the inequality comparison. |
◆ EXPECT_NEAR
#define EXPECT_NEAR |
( |
|
lhs, |
|
|
|
rhs, |
|
|
|
epsilon |
|
) |
| _PW_TEST_EXPECT(_PW_TEST_NEAR(lhs, rhs, epsilon)) |
Verifies that the difference between lhs
and rhs
does not exceed the absolute error bound epsilon
.
- Parameters
-
[in] | lhs | The left side of the comparison. |
[in] | rhs | The right side of the comparison. |
[in] | epsilon | The maximum difference between lhs and rhs . |
◆ EXPECT_STREQ
#define EXPECT_STREQ |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| _PW_TEST_EXPECT(_PW_TEST_C_STR(lhs, rhs, ==)) |
Verifies that the two C strings lhs
and rhs
have the same contents.
- Parameters
-
[in] | lhs | The left side of the equality comparison. |
| [] | rhs The right side of the equality comparison. |
◆ EXPECT_STRNE
#define EXPECT_STRNE |
( |
|
lhs, |
|
|
|
rhs |
|
) |
| _PW_TEST_EXPECT(_PW_TEST_C_STR(lhs, rhs, !=)) |
Verifies that the two C strings lhs
and rhs
have different content.
- Parameters
-
[in] | lhs | The left side of the inequality comparison. |
[in] | rhs | The right side of the inequality comparison. |
◆ EXPECT_TRUE
#define EXPECT_TRUE |
( |
|
expr | ) |
_PW_TEST_EXPECT(_PW_TEST_BOOL(expr, true)) |
Verifies that expr
evaluates to true.
- Parameters
-
[in] | expr | The expression to evaluate. |
◆ PW_TEST_EXPECT_OK
#define PW_TEST_EXPECT_OK |
( |
|
expr | ) |
|
Value: if (cpp20::is_constant_evaluated()) { \
::pw::unit_test::internal::Constexpr_EXPECT_OK( \
::pw::internal::ConvertToStatus(expr)); \
} else \
constexpr Status OkStatus()
Definition: status.h:297
Verifies that expr
is OkStatus()
Converts expr
to a Status value and checks that it is OkStatus()
.
- Parameters
-
[in] | expr | The expression to check. |