Improve UnitTest macros in src/test.cpp
All checks were successful
Run UnitTest / build-and-run-UnitTest (push) Successful in 11s
All checks were successful
Run UnitTest / build-and-run-UnitTest (push) Successful in 11s
This commit is contained in:
parent
4ae6400711
commit
9fc4671bec
1 changed files with 13 additions and 10 deletions
23
src/test.cpp
23
src/test.cpp
|
@ -11,19 +11,21 @@ static int checks_passed = 0;
|
|||
do { \
|
||||
++checks_checked; \
|
||||
if (!(x)) { \
|
||||
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed!\n"; \
|
||||
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed: " \
|
||||
<< #x << '\n'; \
|
||||
} else { \
|
||||
++checks_passed; \
|
||||
} \
|
||||
} while (false);
|
||||
#define CHECK_FALSE(x) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
if (x) { \
|
||||
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed!\n"; \
|
||||
} else { \
|
||||
++checks_passed; \
|
||||
} \
|
||||
#define CHECK_FALSE(x) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
if (x) { \
|
||||
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed: " \
|
||||
<< #x << '\n'; \
|
||||
} else { \
|
||||
++checks_passed; \
|
||||
} \
|
||||
} while (false);
|
||||
|
||||
#define CHECK_FLOAT(var, value) \
|
||||
|
@ -32,7 +34,8 @@ static int checks_passed = 0;
|
|||
if ((var) > (value)-0.0001F && (var) < (value) + 0.0001F) { \
|
||||
++checks_passed; \
|
||||
} else { \
|
||||
std::cout << "CHECK_FLOAT at line " << __LINE__ << " failed!\n"; \
|
||||
std::cout << "CHECK_FLOAT at line " << __LINE__ << " failed: " \
|
||||
<< #var << " != " << #value << '\n'; \
|
||||
} \
|
||||
} while (false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue