Compare commits
No commits in common. "c18765e44a110f2fe4616726305bafadbce4f5e9" and "c016fcdbd987e962b3514aece75a3ef9db01073f" have entirely different histories.
c18765e44a
...
c016fcdbd9
2 changed files with 29 additions and 30 deletions
|
@ -1,7 +1,7 @@
|
|||
#include "test_helpers.h"
|
||||
|
||||
std::atomic_int64_t checks_checked = std::atomic_int64_t(0);
|
||||
std::atomic_int64_t checks_passed = std::atomic_int64_t(0);
|
||||
int checks_checked = 0;
|
||||
int checks_passed = 0;
|
||||
|
||||
int main() {
|
||||
TEST_EC_Bitset();
|
||||
|
@ -37,8 +37,8 @@ int main() {
|
|||
TEST_ECThreadPool_QueryCount();
|
||||
TEST_ECThreadPool_easyStartAndWait();
|
||||
|
||||
std::cout << "checks_checked: " << checks_checked.load() << '\n'
|
||||
<< "checks_passed: " << checks_passed.load() << std::endl;
|
||||
std::cout << "checks_checked: " << checks_checked << '\n'
|
||||
<< "checks_passed: " << checks_passed << std::endl;
|
||||
|
||||
return checks_checked.load() == checks_passed.load() ? 0 : 1;
|
||||
return checks_checked == checks_passed ? 0 : 1;
|
||||
}
|
||||
|
|
|
@ -3,61 +3,60 @@
|
|||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
|
||||
extern std::atomic_int64_t checks_checked;
|
||||
extern std::atomic_int64_t checks_passed;
|
||||
extern int checks_checked;
|
||||
extern int checks_passed;
|
||||
|
||||
// Macros for unit testing.
|
||||
|
||||
#define CHECK_TRUE(x) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if (!(x)) { \
|
||||
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed: " << #x \
|
||||
<< '\n'; \
|
||||
} else { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} \
|
||||
} while (false);
|
||||
#define ASSERT_TRUE(x) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if (!(x)) { \
|
||||
std::cout << "CHECK_TRUE at line " << __LINE__ << " failed: " << #x \
|
||||
<< '\n'; \
|
||||
return; \
|
||||
} else { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} \
|
||||
} while (false);
|
||||
#define CHECK_FALSE(x) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if (x) { \
|
||||
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed: " << #x \
|
||||
<< '\n'; \
|
||||
} else { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} \
|
||||
} while (false);
|
||||
#define ASSERT_FALSE(x) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if (x) { \
|
||||
std::cout << "CHECK_FALSE at line " << __LINE__ << " failed: " << #x \
|
||||
<< '\n'; \
|
||||
return; \
|
||||
} else { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} \
|
||||
} while (false);
|
||||
|
||||
#define CHECK_FLOAT(var, value) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if ((var) > (value) - 0.0001F && (var) < (value) + 0.0001F) { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} else { \
|
||||
std::cout << "CHECK_FLOAT at line " << __LINE__ << " failed: " << #var \
|
||||
<< " != " << #value << '\n'; \
|
||||
|
@ -66,9 +65,9 @@ extern std::atomic_int64_t checks_passed;
|
|||
|
||||
#define CHECK_EQ(var, value) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if ((var) == (value)) { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} else { \
|
||||
std::cout << "CHECK_EQ at line " << __LINE__ << " failed: " << #var \
|
||||
<< " != " << #value << '\n'; \
|
||||
|
@ -76,9 +75,9 @@ extern std::atomic_int64_t checks_passed;
|
|||
} while (false);
|
||||
#define ASSERT_EQ(var, value) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if ((var) == (value)) { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} else { \
|
||||
std::cout << "ASSERT_EQ at line " << __LINE__ << " failed: " << #var \
|
||||
<< " != " << #value << '\n'; \
|
||||
|
@ -87,9 +86,9 @@ extern std::atomic_int64_t checks_passed;
|
|||
} while (false);
|
||||
#define CHECK_NE(var, value) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if ((var) != (value)) { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} else { \
|
||||
std::cout << "CHECK_NE at line " << __LINE__ << " failed: " << #var \
|
||||
<< " == " << #value << '\n'; \
|
||||
|
@ -97,9 +96,9 @@ extern std::atomic_int64_t checks_passed;
|
|||
} while (false);
|
||||
#define CHECK_GE(var, value) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if ((var) >= (value)) { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} else { \
|
||||
std::cout << "CHECK_GE at line " << __LINE__ << " failed: " << #var \
|
||||
<< " < " << #value << '\n'; \
|
||||
|
@ -107,9 +106,9 @@ extern std::atomic_int64_t checks_passed;
|
|||
} while (false);
|
||||
#define CHECK_LE(var, value) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if ((var) <= (value)) { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} else { \
|
||||
std::cout << "CHECK_LE at line " << __LINE__ << " failed: " << #var \
|
||||
<< " > " << #value << '\n'; \
|
||||
|
@ -118,9 +117,9 @@ extern std::atomic_int64_t checks_passed;
|
|||
|
||||
#define CHECK_STREQ(str_a, str_b) \
|
||||
do { \
|
||||
checks_checked.fetch_add(1); \
|
||||
++checks_checked; \
|
||||
if (std::strcmp((str_a), (str_b)) == 0) { \
|
||||
checks_passed.fetch_add(1); \
|
||||
++checks_passed; \
|
||||
} else { \
|
||||
std::cout << "CHECK_STREQ at line " << __LINE__ << "failed: " << #str_a \
|
||||
<< " != " << #str_b << '\n'; \
|
||||
|
|
Loading…
Reference in a new issue