Merge branch 'master' into cxx17
All checks were successful
Run UnitTests / build-and-run-unittests (push) Successful in 31s
All checks were successful
Run UnitTests / build-and-run-unittests (push) Successful in 31s
This commit is contained in:
commit
c18765e44a
2 changed files with 30 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
|||
#include "test_helpers.h"
|
||||
|
||||
int checks_checked = 0;
|
||||
int checks_passed = 0;
|
||||
std::atomic_int64_t checks_checked = std::atomic_int64_t(0);
|
||||
std::atomic_int64_t checks_passed = std::atomic_int64_t(0);
|
||||
|
||||
int main() {
|
||||
TEST_EC_Bitset();
|
||||
|
@ -37,8 +37,8 @@ int main() {
|
|||
TEST_ECThreadPool_QueryCount();
|
||||
TEST_ECThreadPool_easyStartAndWait();
|
||||
|
||||
std::cout << "checks_checked: " << checks_checked << '\n'
|
||||
<< "checks_passed: " << checks_passed << std::endl;
|
||||
std::cout << "checks_checked: " << checks_checked.load() << '\n'
|
||||
<< "checks_passed: " << checks_passed.load() << std::endl;
|
||||
|
||||
return checks_checked == checks_passed ? 0 : 1;
|
||||
return checks_checked.load() == checks_passed.load() ? 0 : 1;
|
||||
}
|
||||
|
|
|
@ -3,60 +3,61 @@
|
|||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
|
||||
extern int checks_checked;
|
||||
extern int checks_passed;
|
||||
extern std::atomic_int64_t checks_checked;
|
||||
extern std::atomic_int64_t checks_passed;
|
||||
|
||||
// Macros for unit testing.
|
||||
|
||||
#define CHECK_TRUE(x) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if (!(x)) { \
|
||||
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed: " << #x \
|
||||
<< '\n'; \
|
||||
} else { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} \
|
||||
} while (false);
|
||||
#define ASSERT_TRUE(x) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if (!(x)) { \
|
||||
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed: " << #x \
|
||||
<< '\n'; \
|
||||
return; \
|
||||
} else { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} \
|
||||
} while (false);
|
||||
#define CHECK_FALSE(x) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if (x) { \
|
||||
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed: " << #x \
|
||||
<< '\n'; \
|
||||
} else { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} \
|
||||
} while (false);
|
||||
#define ASSERT_FALSE(x) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if (x) { \
|
||||
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed: " << #x \
|
||||
<< '\n'; \
|
||||
return; \
|
||||
} else { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} \
|
||||
} while (false);
|
||||
|
||||
#define CHECK_FLOAT(var, value) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if ((var) > (value) - 0.0001F && (var) < (value) + 0.0001F) { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} else { \
|
||||
std::cout << "CHECK_FLOAT at line " << __LINE__ << " failed: " << #var \
|
||||
<< " != " << #value << '\n'; \
|
||||
|
@ -65,9 +66,9 @@ extern int checks_passed;
|
|||
|
||||
#define CHECK_EQ(var, value) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if ((var) == (value)) { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} else { \
|
||||
std::cout << "CHECK_EQ at line " << __LINE__ << " failed: " << #var \
|
||||
<< " != " << #value << '\n'; \
|
||||
|
@ -75,9 +76,9 @@ extern int checks_passed;
|
|||
} while (false);
|
||||
#define ASSERT_EQ(var, value) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if ((var) == (value)) { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} else { \
|
||||
std::cout << "ASSERT_EQ at line " << __LINE__ << " failed: " << #var \
|
||||
<< " != " << #value << '\n'; \
|
||||
|
@ -86,9 +87,9 @@ extern int checks_passed;
|
|||
} while (false);
|
||||
#define CHECK_NE(var, value) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if ((var) != (value)) { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} else { \
|
||||
std::cout << "CHECK_NE at line " << __LINE__ << " failed: " << #var \
|
||||
<< " == " << #value << '\n'; \
|
||||
|
@ -96,9 +97,9 @@ extern int checks_passed;
|
|||
} while (false);
|
||||
#define CHECK_GE(var, value) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if ((var) >= (value)) { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} else { \
|
||||
std::cout << "CHECK_GE at line " << __LINE__ << " failed: " << #var \
|
||||
<< " < " << #value << '\n'; \
|
||||
|
@ -106,9 +107,9 @@ extern int checks_passed;
|
|||
} while (false);
|
||||
#define CHECK_LE(var, value) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if ((var) <= (value)) { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} else { \
|
||||
std::cout << "CHECK_LE at line " << __LINE__ << " failed: " << #var \
|
||||
<< " > " << #value << '\n'; \
|
||||
|
@ -117,9 +118,9 @@ extern int checks_passed;
|
|||
|
||||
#define CHECK_STREQ(str_a, str_b) \
|
||||
do { \
|
||||
++checks_checked; \
|
||||
checks_checked.fetch_add(1); \
|
||||
if (std::strcmp((str_a), (str_b)) == 0) { \
|
||||
++checks_passed; \
|
||||
checks_passed.fetch_add(1); \
|
||||
} else { \
|
||||
std::cout << "CHECK_STREQ at line " << __LINE__ << "failed: " << #str_a \
|
||||
<< " != " << #str_b << '\n'; \
|
||||
|
|
Loading…
Reference in a new issue