Assertions work the same as expectations except they stop the execution of the test as soon as a failed condition is met.
Macros | |
| #define | ASSERT_TRUE(expr) _PW_TEST_ASSERT(_PW_TEST_BOOL(expr, true)) |
| #define | ASSERT_FALSE(expr) _PW_TEST_ASSERT(_PW_TEST_BOOL(expr, false)) |
| #define | ASSERT_EQ(lhs, rhs) _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, ==)) |
| #define | ASSERT_NE(lhs, rhs) _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, !=)) |
| #define | ASSERT_GT(lhs, rhs) _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, >)) |
| #define | ASSERT_GE(lhs, rhs) _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, >=)) |
| #define | ASSERT_LT(lhs, rhs) _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, <)) |
| #define | ASSERT_LE(lhs, rhs) _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, <=)) |
| #define | ASSERT_NEAR(lhs, rhs, epsilon) _PW_TEST_ASSERT(_PW_TEST_NEAR(lhs, rhs, epsilon)) |
| #define | ASSERT_FLOAT_EQ(lhs, rhs) |
| #define | ASSERT_DOUBLE_EQ(lhs, rhs) |
| #define | ASSERT_STREQ(lhs, rhs) _PW_TEST_ASSERT(_PW_TEST_C_STR(lhs, rhs, ==)) |
| #define | ASSERT_STRNE(lhs, rhs) _PW_TEST_ASSERT(_PW_TEST_C_STR(lhs, rhs, !=)) |
| #define | PW_TEST_ASSERT_OK(expr) |
See PW_TEST_EXPECT_OK. | |
| #define | PW_TEST_ASSERT_OK_AND_ASSIGN(lhs, rexpr) |
| #define ASSERT_DOUBLE_EQ | ( | lhs, | |
| rhs | |||
| ) |
See EXPECT_DOUBLE_EQ.
| #define ASSERT_EQ | ( | lhs, | |
| rhs | |||
| ) | _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, ==)) |
See EXPECT_EQ.
| #define ASSERT_FALSE | ( | expr | ) | _PW_TEST_ASSERT(_PW_TEST_BOOL(expr, false)) |
See EXPECT_FALSE.
| #define ASSERT_FLOAT_EQ | ( | lhs, | |
| rhs | |||
| ) |
See EXPECT_FLOAT_EQ.
| #define ASSERT_GE | ( | lhs, | |
| rhs | |||
| ) | _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, >=)) |
See EXPECT_GE.
| #define ASSERT_GT | ( | lhs, | |
| rhs | |||
| ) | _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, >)) |
See EXPECT_GT.
| #define ASSERT_LE | ( | lhs, | |
| rhs | |||
| ) | _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, <=)) |
See EXPECT_LE.
| #define ASSERT_LT | ( | lhs, | |
| rhs | |||
| ) | _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, <)) |
See EXPECT_LT.
| #define ASSERT_NE | ( | lhs, | |
| rhs | |||
| ) | _PW_TEST_ASSERT(_PW_TEST_OP(lhs, rhs, !=)) |
See EXPECT_NE.
| #define ASSERT_NEAR | ( | lhs, | |
| rhs, | |||
| epsilon | |||
| ) | _PW_TEST_ASSERT(_PW_TEST_NEAR(lhs, rhs, epsilon)) |
See EXPECT_NEAR.
| #define ASSERT_STREQ | ( | lhs, | |
| rhs | |||
| ) | _PW_TEST_ASSERT(_PW_TEST_C_STR(lhs, rhs, ==)) |
See EXPECT_STREQ.
| #define ASSERT_STRNE | ( | lhs, | |
| rhs | |||
| ) | _PW_TEST_ASSERT(_PW_TEST_C_STR(lhs, rhs, !=)) |
See EXPECT_STRNE.
| #define ASSERT_TRUE | ( | expr | ) | _PW_TEST_ASSERT(_PW_TEST_BOOL(expr, true)) |
See EXPECT_TRUE.
| #define PW_TEST_ASSERT_OK | ( | expr | ) |
See PW_TEST_EXPECT_OK.
| #define PW_TEST_ASSERT_OK_AND_ASSIGN | ( | lhs, | |
| rexpr | |||
| ) |
Executes an expression that returns a pw::Result or pw::StatusWithSize and assigns or moves that value to lhs if the error code is OK. If the status is non-OK, generates a test failure and returns from the current function, which must have a void return type.
Example: Declaring and initializing a new value. E.g.: PW_TEST_ASSERT_OK_AND_ASSIGN(auto value, MaybeGetValue(arg)); PW_TEST_ASSERT_OK_AND_ASSIGN(const ValueType value, MaybeGetValue(arg));
Example: Assigning to an existing value ValueType value; PW_TEST_ASSERT_OK_AND_ASSIGN(value, MaybeGetValue(arg));
The value assignment example would expand into something like: auto status_or_value = MaybeGetValue(arg); PW_TEST_ASSERT_OK(status_or_value.status()); value = status_or_value.ValueOrDie();
WARNING: PW_TEST_ASSERT_OK_AND_ASSIGN expand into multiple statements; it cannot be used in a single statement (e.g. as the body of an if statement without {})!
| [in] | lhs | Variable to assign unwrapped value to |
| [in] | rexpr | Expression to unwrap. Must be a Result or StatusWithSize. |