| Cutter Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
Assertions with C++ supportAssertions with C++ support — Checks that your program works as you expect with C++ support. |
#define cppcut_assert_equal (expected, actual, ...) #define cppcut_assert_not_equal (expected, actual, ...) #define cppcut_assert_not_null (object, ...) #define cppcut_assert_null (object, ...) #define cppcut_assert_operator (lhs, operator, rhs, ...)
#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"));
|
an expected value. |
|
an actual value. |
|
an optional message. Use cppcut_message() for this. |
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"));
|
an expected value. |
|
an actual value. |
|
an optional message. Use cppcut_message() for this. |
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
|
the object to be checked. |
|
an optional message. Use cppcut_message() for this. |
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
|
the object to be checked. |
|
an optional message. Use cppcut_message() for this. |
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
|
a left hand side value. |
|
a binary operator. |
|
a right hand side value. |
|
an optional message. Use cppcut_message() for this. |
Since 1.2.0