CPUnit 0.95 (beta)
The REAL C++ port of JUnit.
|
#include "cpunit_Assert.hpp"
#include "cpunit_FuncTestRegistrar.hpp"
#include "cpunit_ExceptionTestRegistrar.hpp"
#include "cpunit_FixtureRegistrar.hpp"
#include "cpunit_impl_StrCat.hpp"
Go to the source code of this file.
Defines | |
#define | CPUNIT_STRINGIFY(x) #x |
Forward stringify macro for full expansion macros when stringifying. | |
#define | CPUNIT_GTEST(x) CPUNIT_TEST(,x) |
Test case registrator for global test functions. | |
#define | CPUNIT_TEST(n, f) |
Test case registrator for test functions in a suite/namespace. | |
#define | CPUNIT_GTEST_EX_ANY(f) CPUNIT_TEST_EX_ANY(,f) |
Test case registrator for global tests expecting an exception. | |
#define | CPUNIT_GTEST_EX(f, E) CPUNIT_TEST_EX(,f,E) |
Test case registrator for global tests expecting an exception. | |
#define | CPUNIT_TEST_EX_ANY(n, f) CPUNIT_TEST_EX(n, f, cpunit::AnyType) |
Test case registrator for tests expecting an exception. | |
#define | CPUNIT_TEST_EX(n, f, E) |
Test case registrator for tests expecting an exception. | |
#define | CPUNIT_SET_UP(n) |
Set-up method registrator. | |
#define | CPUNIT_TEAR_DOWN(n) |
Tear-down method registrator. | |
#define | CPUNIT_STR(x) (::cpunit::impl::StrCat()<<x).str() |
String-generator helper. | |
#define | CPUNIT_FAIL() cpunit::fail (CPUNIT_STR(" At line " << __LINE__ << " of " << __FILE__)) |
Convenience macro for calling fail(). | |
#define | CPUNIT_FAIL1(m) cpunit::fail (CPUNIT_STR(" At line " << __LINE__ << " of " << __FILE__ << ": " << m)) |
Convenience macro for calling fail(const std::string&). | |
#define | CPUNIT_ASSERT(x) cpunit::assert_true (CPUNIT_STR("At line " << __LINE__ << " of " << __FILE__ << " Stmt: '" << #x << '\''), x) |
Convenience macro for calling assert_true. | |
#define | CPUNIT_ASSERT1(m, x) cpunit::assert_true (CPUNIT_STR("At line " << __LINE__ << " of " << __FILE__ << ": " << m << " Stmt: '" << #x << '\''), x) |
Convenience macro for calling assert_true. | |
#define | CPUNIT_DISPROVE(x) cpunit::assert_false(CPUNIT_STR("At line " << __LINE__ << " of " << __FILE__ << " Stmt: '" << #x << '\''), x) |
Convenience macro for calling assert_false. | |
#define | CPUNIT_DISPROVE1(m, x) cpunit::assert_false(CPUNIT_STR("At line " << __LINE__ << " of " << __FILE__ << ": " << m << " Stmt: '" << #x << '\''), x) |
Convenience macro for calling assert_false. |
#define CPUNIT_ASSERT | ( | x | ) | cpunit::assert_true (CPUNIT_STR("At line " << __LINE__ << " of " << __FILE__ << " Stmt: '" << #x << '\''), x) |
Convenience macro for calling assert_true.
Will use the statement as message, and will add the line number to the message as well.
x | The statement to verify |
Definition at line 147 of file cpunit.hpp.
#define CPUNIT_ASSERT1 | ( | m, | |
x | |||
) | cpunit::assert_true (CPUNIT_STR("At line " << __LINE__ << " of " << __FILE__ << ": " << m << " Stmt: '" << #x << '\''), x) |
Convenience macro for calling assert_true.
Will use the statement as part of the message, and will add the line number to the message as well.
m | A stream-formatted statement which will become part of the message. |
x | The statement to verify |
Definition at line 156 of file cpunit.hpp.
#define CPUNIT_DISPROVE | ( | x | ) | cpunit::assert_false(CPUNIT_STR("At line " << __LINE__ << " of " << __FILE__ << " Stmt: '" << #x << '\''), x) |
Convenience macro for calling assert_false.
Will use the statement as message, and will add the line number to the message as well.
x | The statement to falsify |
Definition at line 164 of file cpunit.hpp.
#define CPUNIT_DISPROVE1 | ( | m, | |
x | |||
) | cpunit::assert_false(CPUNIT_STR("At line " << __LINE__ << " of " << __FILE__ << ": " << m << " Stmt: '" << #x << '\''), x) |
Convenience macro for calling assert_false.
Will use the statement as message, and will add the line number to the message as well.
m | A stream-formatted statement which will become part of the message. |
x | The statement to falsify |
Definition at line 173 of file cpunit.hpp.
#define CPUNIT_FAIL | ( | ) | cpunit::fail (CPUNIT_STR(" At line " << __LINE__ << " of " << __FILE__)) |
Convenience macro for calling fail().
Will insert the line number in the error message.
Definition at line 132 of file cpunit.hpp.
#define CPUNIT_FAIL1 | ( | m | ) | cpunit::fail (CPUNIT_STR(" At line " << __LINE__ << " of " << __FILE__ << ": " << m)) |
Convenience macro for calling fail(const std::string&).
Will prepend the line number to the error message.
m | A stream-formatted statement which will become part of the message. |
Definition at line 139 of file cpunit.hpp.
#define CPUNIT_GTEST | ( | x | ) | CPUNIT_TEST(,x) |
Test case registrator for global test functions.
x | The name of the test to register. |
Definition at line 47 of file cpunit.hpp.
#define CPUNIT_GTEST_EX | ( | f, | |
E | |||
) | CPUNIT_TEST_EX(,f,E) |
Test case registrator for global tests expecting an exception.
The test will only succeed if an exception of type E
is thrown from the tested code.
f | The name of the test case to register |
E | The type of exception to expect |
Definition at line 73 of file cpunit.hpp.
#define CPUNIT_GTEST_EX_ANY | ( | f | ) | CPUNIT_TEST_EX_ANY(,f) |
Test case registrator for global tests expecting an exception.
The test will succeed if and only if an exception is thrown from the tested code. The thrown exception may be of any type.
f | The name of the test case to register |
Definition at line 65 of file cpunit.hpp.
#define CPUNIT_SET_UP | ( | n | ) |
void set_up(); \ namespace { static ::cpunit::FixtureRegistrar __set_up_registrar (CPUNIT_STRINGIFY(n), "set_up", __FILE__, __LINE__, &n::set_up, cpunit::FixtureRegistrar::SET_UP); } \ void set_up()
Set-up method registrator.
There can only be one set-up method for each suite/namespace.
n | The namespace to register the set-up method for. |
Definition at line 100 of file cpunit.hpp.
#define CPUNIT_STR | ( | x | ) | (::cpunit::impl::StrCat()<<x).str() |
String-generator helper.
Can be used with the streaming-operator in-between arguments:
for (int i=0; i<12; ++i) { assert_true(CPUNIT_STR("The test failed for i="<<i), i < 7); }
x | The sequence of arguments to stream to a string. |
Definition at line 126 of file cpunit.hpp.
#define CPUNIT_STRINGIFY | ( | x | ) | #x |
Forward stringify macro for full expansion macros when stringifying.
Definition at line 41 of file cpunit.hpp.
#define CPUNIT_TEAR_DOWN | ( | n | ) |
void tear_down(); \ namespace { static ::cpunit::FixtureRegistrar __tear_down_registrar (CPUNIT_STRINGIFY(n), "tear_down", __FILE__, __LINE__, &n::tear_down, cpunit::FixtureRegistrar::TEAR_DOWN); } \ void tear_down()
Tear-down method registrator.
There can only be one tear-down method for each suite/namespace.
n | The namespace to register the tear-down method for. |
Definition at line 109 of file cpunit.hpp.
#define CPUNIT_TEST | ( | n, | |
f | |||
) |
void f(); \ namespace { static ::cpunit::FuncTestRegistrar __##f##_registrar (CPUNIT_STRINGIFY(n), CPUNIT_STRINGIFY(f), __FILE__, __LINE__, &n::f); } \ void f()
Test case registrator for test functions in a suite/namespace.
n | The namespace name where the test case resides. |
f | The name of the test case to register. |
Definition at line 54 of file cpunit.hpp.
#define CPUNIT_TEST_EX | ( | n, | |
f, | |||
E | |||
) |
void f(); \ namespace { static ::cpunit::ExceptionTestRegistrar<E> __##f##_registrar (CPUNIT_STRINGIFY(n), CPUNIT_STRINGIFY(f), __FILE__, __LINE__, &n::f); } \ void f()
Test case registrator for tests expecting an exception.
The test will only succeed if an exception of type E
is thrown from the tested code.
n | The namespace (suite) where the test case resides |
f | The name of the test case to register |
E | The type of exception to expect |
Definition at line 91 of file cpunit.hpp.
#define CPUNIT_TEST_EX_ANY | ( | n, | |
f | |||
) | CPUNIT_TEST_EX(n, f, cpunit::AnyType) |
Test case registrator for tests expecting an exception.
The test will succeed if and only if an exception is thrown from the tested code. The thrown exception may be of any type.
n | The namespace (suite) where the test case resides |
f | The name of the test case to register |
Definition at line 82 of file cpunit.hpp.