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 { \
|
do { \
|
||||||
++checks_checked; \
|
++checks_checked; \
|
||||||
if (!(x)) { \
|
if (!(x)) { \
|
||||||
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed!\n"; \
|
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed: " \
|
||||||
|
<< #x << '\n'; \
|
||||||
} else { \
|
} else { \
|
||||||
++checks_passed; \
|
++checks_passed; \
|
||||||
} \
|
} \
|
||||||
} while (false);
|
} while (false);
|
||||||
#define CHECK_FALSE(x) \
|
#define CHECK_FALSE(x) \
|
||||||
do { \
|
do { \
|
||||||
++checks_checked; \
|
++checks_checked; \
|
||||||
if (x) { \
|
if (x) { \
|
||||||
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed!\n"; \
|
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed: " \
|
||||||
} else { \
|
<< #x << '\n'; \
|
||||||
++checks_passed; \
|
} else { \
|
||||||
} \
|
++checks_passed; \
|
||||||
|
} \
|
||||||
} while (false);
|
} while (false);
|
||||||
|
|
||||||
#define CHECK_FLOAT(var, value) \
|
#define CHECK_FLOAT(var, value) \
|
||||||
|
@ -32,7 +34,8 @@ static int checks_passed = 0;
|
||||||
if ((var) > (value)-0.0001F && (var) < (value) + 0.0001F) { \
|
if ((var) > (value)-0.0001F && (var) < (value) + 0.0001F) { \
|
||||||
++checks_passed; \
|
++checks_passed; \
|
||||||
} else { \
|
} else { \
|
||||||
std::cout << "CHECK_FLOAT at line " << __LINE__ << " failed!\n"; \
|
std::cout << "CHECK_FLOAT at line " << __LINE__ << " failed: " \
|
||||||
|
<< #var << " != " << #value << '\n'; \
|
||||||
} \
|
} \
|
||||||
} while (false);
|
} while (false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue