|
| #define | QUICKCPPLIB_BOOST_UNIT_TEST_IMPL 0 |
| |
| #define | QUICKCPPLIB_BOOST_UNIT_TEST_FAIL longjmp(QUICKCPPLIB_NAMESPACE::unit_test::test_case_failed(), 1) |
| |
| #define | QUICKCPPLIB_BOOST_UNIT_CHECK_FAIL(type, expr) |
| |
| #define | QUICKCPPLIB_BOOST_UNIT_CHECK_PASS(type, expr) ++QUICKCPPLIB_NAMESPACE::unit_test::current_test_case()->passes |
| |
| #define | QUICKCPPLIB_BOOST_UNIT_REQUIRE_FAIL(type, expr) |
| |
| #define | QUICKCPPLIB_BOOST_UNIT_REQUIRE_PASS(type, expr) ++QUICKCPPLIB_NAMESPACE::unit_test::current_test_case()->passes |
| |
| #define | BOOST_TEST_MESSAGE(msg) std::cout << "INFO: " << msg << std::endl |
| |
| #define | BOOST_WARN_MESSAGE(pred, msg) |
| |
| #define | BOOST_FAIL(msg) |
| |
| #define | BOOST_CHECK_MESSAGE(pred, msg) |
| |
| #define | BOOST_CHECK(expr) |
| |
| #define | BOOST_CHECK_EQUAL(expr1, expr2) BOOST_CHECK((expr1) == (expr2)) |
| |
| #define | BOOST_CHECK_THROWS(expr) |
| |
| #define | BOOST_CHECK_THROW(expr, type) |
| |
| #define | BOOST_CHECK_NO_THROW(expr) expr |
| |
| #define | BOOST_REQUIRE(expr) |
| |
| #define | BOOST_REQUIRE_THROWS(expr) |
| |
| #define | BOOST_CHECK_REQUIRE(expr, type) |
| |
| #define | BOOST_REQUIRE_NO_THROW(expr) expr |
| |
| #define | BOOST_AUTO_TEST_SUITE3(a, b) a##b |
| |
| #define | BOOST_AUTO_TEST_SUITE2(a, b) BOOST_AUTO_TEST_SUITE3(a, b) |
| |
| #define | BOOST_AUTO_TEST_SUITE(name) |
| |
| #define | BOOST_AUTO_TEST_SUITE_END() } |
| |
| #define | QUICKCPPLIB_BOOST_UNIT_TEST_CASE_NAME(name) #name |
| |
| #define | QUICKCPPLIB_BOOST_UNIT_TEST_CASE_UNIQUE(prefix) BOOST_AUTO_TEST_SUITE2(prefix, __COUNTER__) |
| |
| #define | BOOST_AUTO_TEST_CASE2(test_name, desc, func_name) |
| |
| #define | BOOST_AUTO_TEST_CASE(test_name, desc) |
| |
| #define | QUICKCPPLIB_BOOST_UNIT_TEST_RUN_TESTS(argc, argv) QUICKCPPLIB_NAMESPACE::unit_test::run(argc, argv) |
| |
| #define | BOOST_BINDLIB_ENABLE_MULTIPLE_DEFINITIONS inline |
| |
QuickCppLib comes with a minimal emulation of Boost.Test based on one of two underlying unit test engines:
QUICKCPPLIB_BOOST_UNIT_TEST_IMPL = 0 (the default)
An internal extremely lightweight engine which works well with exceptions and RTTI disabled. It works fine with multithreaded test cases, and can write results to a JUnit XML file for consumption by Jenkins etc. Its implementation is less than two hundred lines of C++, so it isn't particularly configurable nor flexible. In particular it maintains no history of checks, no stdio redirection, no trapping of signals, no interception of failed asserts etc. If a check fails it simply prints immediately what failed to stderr and increments a fail counter. Despite its simplicity you'll probably find it works plenty well for most use cases and it has almost zero overhead either at compile or runtime.
Note that if exceptions are disabled, those checks and requires testing that things throw are implement as no ops for obvious reasons.
- Warning
- A requirement failure is handled by throwing a magic exception type to abort the test case and prevent execution of later code, unwinding the stack and releasing any resources allocated up to that point. If exceptions are disabled,
longjmp() is used instead and therefore stack unwinding does not occur, leaking any stack based resources.
- Note
- Almost all the macros used by this internal engine can be redefined before including the header file. It's been deliberately made highly customisable.
QUICKCPPLIB_BOOST_UNIT_TEST_IMPL = 1
- Use Phil Nash's CATCH (https://github.com/philsquared/Catch) header only test engine. The Boost.Test macros simply call CATCH equivalents. The CATCH used is actually a fork of Phil's with a giant mutex poked in so multiple threads can do checks concurrently.
◆ QUICKCPPLIB_BOOST_UNIT_TEST_IMPL
| #define QUICKCPPLIB_BOOST_UNIT_TEST_IMPL 0 |
◆ QUICKCPPLIB_BOOST_UNIT_TEST_FAIL
| #define QUICKCPPLIB_BOOST_UNIT_TEST_FAIL longjmp(QUICKCPPLIB_NAMESPACE::unit_test::test_case_failed(), 1) |
◆ QUICKCPPLIB_BOOST_UNIT_CHECK_FAIL
| #define QUICKCPPLIB_BOOST_UNIT_CHECK_FAIL |
( |
|
type, |
|
|
|
expr |
|
) |
| |
Value: ++QUICKCPPLIB_NAMESPACE::unit_test::current_test_case()->fails; \
std::cerr << QUICKCPPLIB_NAMESPACE::unit_test::yellow << "CHECK " type "(" #expr ") FAILED" \
<< QUICKCPPLIB_NAMESPACE::unit_test::white << " at " << __FILE__ << ":" << __LINE__ << std::endl
430 :" << __LINE__ << std::endl
◆ QUICKCPPLIB_BOOST_UNIT_CHECK_PASS
| #define QUICKCPPLIB_BOOST_UNIT_CHECK_PASS |
( |
|
type, |
|
|
|
expr |
|
) |
| ++QUICKCPPLIB_NAMESPACE::unit_test::current_test_case()->passes |
◆ QUICKCPPLIB_BOOST_UNIT_REQUIRE_FAIL
| #define QUICKCPPLIB_BOOST_UNIT_REQUIRE_FAIL |
( |
|
type, |
|
|
|
expr |
|
) |
| |
Value: ++QUICKCPPLIB_NAMESPACE::unit_test::current_test_case()->fails; \
std::cerr << QUICKCPPLIB_NAMESPACE::unit_test::red << "REQUIRE " type "(" #expr ") FAILED" \
<< QUICKCPPLIB_NAMESPACE::unit_test::white << " at " << __FILE__ << ":" << __LINE__ << std::endl; \
#define QUICKCPPLIB_BOOST_UNIT_TEST_FAIL
Definition unit_test.hpp:423
439 :" << __LINE__ << std::endl; \
440 QUICKCPPLIB_BOOST_UNIT_TEST_FAIL
◆ QUICKCPPLIB_BOOST_UNIT_REQUIRE_PASS
| #define QUICKCPPLIB_BOOST_UNIT_REQUIRE_PASS |
( |
|
type, |
|
|
|
expr |
|
) |
| ++QUICKCPPLIB_NAMESPACE::unit_test::current_test_case()->passes |
◆ BOOST_TEST_MESSAGE
| #define BOOST_TEST_MESSAGE |
( |
|
msg | ) |
std::cout << "INFO: " << msg << std::endl |
◆ BOOST_WARN_MESSAGE
| #define BOOST_WARN_MESSAGE |
( |
|
pred, |
|
|
|
msg |
|
) |
| |
Value: if(!(pred)) \
std::cerr << QUICKCPPLIB_NAMESPACE::unit_test::yellow << "WARNING: " << msg \
<< QUICKCPPLIB_NAMESPACE::unit_test::normal << std::endl
449 : " << msg \
450 << QUICKCPPLIB_NAMESPACE::unit_test::normal << std::endl
◆ BOOST_FAIL
| #define BOOST_FAIL |
( |
|
msg | ) |
|
Value: std::cerr << QUICKCPPLIB_NAMESPACE::unit_test::red << "FAILURE: " << msg << QUICKCPPLIB_NAMESPACE::unit_test::normal \
<< std::endl; \
452 : " << msg << QUICKCPPLIB_NAMESPACE::unit_test::normal \
453 << std::endl; \
454 QUICKCPPLIB_BOOST_UNIT_TEST_FAIL
◆ BOOST_CHECK_MESSAGE
| #define BOOST_CHECK_MESSAGE |
( |
|
pred, |
|
|
|
msg |
|
) |
| |
Value: if(!(pred)) \
std::cout << "INFO: " << msg << std::endl
457 : " << msg << std::endl
◆ BOOST_CHECK
| #define BOOST_CHECK |
( |
|
expr | ) |
|
Value: if(!(expr)) \
{ \
QUICKCPPLIB_BOOST_UNIT_CHECK_FAIL(, expr); \
} \
\
else \
{ \
QUICKCPPLIB_BOOST_UNIT_CHECK_PASS(, expr); \
}
461 { \
462 QUICKCPPLIB_BOOST_UNIT_CHECK_FAIL(, expr); \
463 } \
464 \
465 else \
466 { \
467 QUICKCPPLIB_BOOST_UNIT_CHECK_PASS(, expr); \
468 }
◆ BOOST_CHECK_EQUAL
| #define BOOST_CHECK_EQUAL |
( |
|
expr1, |
|
|
|
expr2 |
|
) |
| BOOST_CHECK((expr1) == (expr2)) |
◆ BOOST_CHECK_THROWS
| #define BOOST_CHECK_THROWS |
( |
|
expr | ) |
|
◆ BOOST_CHECK_THROW
| #define BOOST_CHECK_THROW |
( |
|
expr, |
|
|
|
type |
|
) |
| |
◆ BOOST_CHECK_NO_THROW
| #define BOOST_CHECK_NO_THROW |
( |
|
expr | ) |
expr |
◆ BOOST_REQUIRE
| #define BOOST_REQUIRE |
( |
|
expr | ) |
|
Value: if(!(expr)) \
{ \
QUICKCPPLIB_BOOST_UNIT_REQUIRE_FAIL(, expr); \
} \
\
{ \
QUICKCPPLIB_BOOST_UNIT_REQUIRE_PASS(, expr); \
}
532 { \
533 QUICKCPPLIB_BOOST_UNIT_REQUIRE_FAIL(, expr); \
534 } \
535 \
536 { \
537 QUICKCPPLIB_BOOST_UNIT_REQUIRE_PASS(, expr); \
538 }
◆ BOOST_REQUIRE_THROWS
| #define BOOST_REQUIRE_THROWS |
( |
|
expr | ) |
|
◆ BOOST_CHECK_REQUIRE
| #define BOOST_CHECK_REQUIRE |
( |
|
expr, |
|
|
|
type |
|
) |
| |
◆ BOOST_REQUIRE_NO_THROW
| #define BOOST_REQUIRE_NO_THROW |
( |
|
expr | ) |
expr |
◆ BOOST_AUTO_TEST_SUITE3
| #define BOOST_AUTO_TEST_SUITE3 |
( |
|
a, |
|
|
|
b |
|
) |
| a##b |
◆ BOOST_AUTO_TEST_SUITE2
◆ BOOST_AUTO_TEST_SUITE
| #define BOOST_AUTO_TEST_SUITE |
( |
|
name | ) |
|
Value:
{ \
static QUICKCPPLIB_NAMESPACE::unit_test::test_suite_registration boostlite_auto_test_suite_registration(#name);
#define BOOST_AUTO_TEST_SUITE2(a, b)
Definition unit_test.hpp:599
602 { \
603 static QUICKCPPLIB_NAMESPACE::unit_test::test_suite_registration boostlite_auto_test_suite_registration(#name);
◆ BOOST_AUTO_TEST_SUITE_END
| #define BOOST_AUTO_TEST_SUITE_END |
( |
| ) |
} |
◆ QUICKCPPLIB_BOOST_UNIT_TEST_CASE_NAME
| #define QUICKCPPLIB_BOOST_UNIT_TEST_CASE_NAME |
( |
|
name | ) |
#name |
◆ QUICKCPPLIB_BOOST_UNIT_TEST_CASE_UNIQUE
◆ BOOST_AUTO_TEST_CASE2
| #define BOOST_AUTO_TEST_CASE2 |
( |
|
test_name, |
|
|
|
desc, |
|
|
|
func_name |
|
) |
| |
Value: \
static void func_name(); \
\
static QUICKCPPLIB_NAMESPACE::unit_test::test_case_registration
BOOST_AUTO_TEST_SUITE2(func_name, _registration)( \
static_cast<const char *>(test_name), static_cast<const char *>(desc), func_name); \
\
static void func_name()
◆ BOOST_AUTO_TEST_CASE
| #define BOOST_AUTO_TEST_CASE |
( |
|
test_name, |
|
|
|
desc |
|
) |
| |
Value:
#define QUICKCPPLIB_BOOST_UNIT_TEST_CASE_NAME(name)
Definition unit_test.hpp:608
#define QUICKCPPLIB_BOOST_UNIT_TEST_CASE_UNIQUE(prefix)
Definition unit_test.hpp:610
#define BOOST_AUTO_TEST_CASE2(test_name, desc, func_name)
Definition unit_test.hpp:611
◆ QUICKCPPLIB_BOOST_UNIT_TEST_RUN_TESTS
◆ BOOST_BINDLIB_ENABLE_MULTIPLE_DEFINITIONS
| #define BOOST_BINDLIB_ENABLE_MULTIPLE_DEFINITIONS inline |
◆ main()
706{
708 return result;
709}
#define QUICKCPPLIB_BOOST_UNIT_TEST_RUN_TESTS(argc, argv)
Definition unit_test.hpp:623