mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-27 00:28:49 +03:00
test when an assert fails.
The following macro has been added:
REQUIRE
An example of when these type of checks are useful:
std::vector<int> v = foo();
REQUIRE(CHECK_EQUAL(3, v.size())); // test stops here on a fail
// so we don't segfault looking at
// v[0] below.
CHECK_EQUAL(1, v[0]);
CHECK_EQUAL(2, v[1]);
CHECK_EQUAL(3, v[2]);
Multiple checks are supported as follows:
REQUIRE({
CHECK_EQUAL(1, 2);
CHECK(true);
};
In the multiple check scenario, all the checks in the REQUIRE block will
be run. After which, if any failures were reported, the TEST case will
be stopped.
When UNITTEST_NO_EXCEPTIONS is defined, REQUIRE is a noop.
12 lines
225 B
C
12 lines
225 B
C
#ifndef UNITTESTPP_H
|
|
#define UNITTESTPP_H
|
|
|
|
#include "Config.h"
|
|
#include "TestMacros.h"
|
|
#include "CheckMacros.h"
|
|
#include "RequireMacros.h"
|
|
#include "TestRunner.h"
|
|
#include "TimeConstraint.h"
|
|
#include "ReportAssert.h"
|
|
|
|
#endif
|