Top | ![]() |
![]() |
![]() |
![]() |
Assertions with C++ supportAssertions with C++ support — Checks that your program works as you expect with C++ support. |
#define | cppcut_assert_equal() |
#define | cppcut_assert_not_equal() |
#define | cppcut_assert_null() |
#define | cppcut_assert_not_null() |
#define | cppcut_assert_operator() |
#define cppcut_assert_equal(expected, actual, ...)
This assertion is a generic method based on template. You
can pass any object's reference as expected
and actual
.
Passes if expected
== actual
.
e.g.:
cppcut_assert_equal(3, 1 + 2); cppcut_assert_equal(3, 1 + 2, cppcut_message("easy expression")); cppcut_assert_equal(3, 1 + 2, cppcut_message() << "easy expression"));
expected |
an expected value. |
|
actual |
an actual value. |
|
... |
an optional message. Use |
Since 1.0.9
#define cppcut_assert_not_equal(expected, actual, ...)
This assertion is a generic method based on template. You
can pass any object's reference as expected
and actual
.
Passes if expected
!= actual
.
e.g.:
cppcut_assert_not_equal(3, 3 + 1); cppcut_assert_not_equal(3, 3 + 1, cppcut_message("easy expression")); cppcut_assert_not_equal(3, 3 + 1, cppcut_message() << "easy expression"));
expected |
an expected value. |
|
actual |
an actual value. |
|
... |
an optional message. Use |
Since 1.2.0
#define cppcut_assert_null(object, ...)
This assertion is a generic method based on template. You
can pass any object's pointer as object
.
Passes if object
is NULL
.
e.g.:
std::string message("hello"); std::string *not_null_string = &message; std::string *null_string = NULL; cppcut_assert_null(not_null_string); // fail cppcut_assert_null(null_string); // pass
Since 1.2.0
#define cppcut_assert_not_null(object, ...)
This assertion is a generic method based on template. You
can pass any object's pointer as object
.
Passes if object
is not NULL
.
e.g.:
std::string message("hello"); std::string *not_null_string = &message; std::string *null_string = NULL; cppcut_assert_not_null(not_null_string); // pass cppcut_assert_not_null(null_string); // fail
Since 1.2.0
#define cppcut_assert_operator(lhs, operator, rhs, ...)
This assertion is a generic method based on template. You
can pass any object as lhs
and rhs
.
Passes if (lhs
operator
rhs
) is TRUE.
e.g.:
cppcut_assert_operator(1, <, 2); // pass cppcut_assert_operator(1, >, 2); // fail
lhs |
a left hand side value. |
|
operator |
a binary operator. |
|
rhs |
a right hand side value. |
|
... |
an optional message. Use |
Since 1.2.0