Commit e7b56d4
Introducing additional functionality to allow client code to stop a unit
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.1 parent 5b34768 commit e7b56d4
3 files changed
Lines changed: 871 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
0 commit comments