};
// Runs a unit test and reports results
-#define TEST(fxn, ...) do { \
+#define TEST(fxn, ...) { \
u64 t1 = porting::getTimeMs(); \
try { \
fxn(__VA_ARGS__); \
num_tests_run++; \
u64 tdiff = porting::getTimeMs() - t1; \
rawstream << #fxn << " - " << tdiff << "ms" << std::endl; \
-} while (0)
+}
// Asserts the specified condition is true, or fails the current unit test
-#define UASSERT(x) do { \
+#define UASSERT(x) \
if (!(x)) { \
rawstream << "Test assertion failed: " #x << std::endl \
<< " at " << fs::GetFilenameFromPath(__FILE__) \
<< ":" << __LINE__ << std::endl; \
throw TestFailedException(); \
- } \
-} while (0)
+ }
// Asserts the specified condition is true, or fails the current unit test
// and prints the format specifier fmt
-#define UTEST(x, fmt, ...) do { \
+#define UTEST(x, fmt, ...) \
if (!(x)) { \
char utest_buf[1024]; \
snprintf(utest_buf, sizeof(utest_buf), fmt, __VA_ARGS__); \
<< " at " << fs::GetFilenameFromPath(__FILE__) \
<< ":" << __LINE__ << std::endl; \
throw TestFailedException(); \
- } \
-} while (0)
+ }
// Asserts the comparison specified by CMP is true, or fails the current unit test
-#define UASSERTCMP(T, CMP, actual, expected) do { \
+#define UASSERTCMP(T, CMP, actual, expected) { \
T a = (actual); \
T e = (expected); \
if (!(a CMP e)) { \
<< e << std::endl; \
throw TestFailedException(); \
} \
-} while (0)
+}
#define UASSERTEQ(T, actual, expected) UASSERTCMP(T, ==, actual, expected)
// UASSERTs that the specified exception occurs
-#define EXCEPTION_CHECK(EType, code) do { \
+#define EXCEPTION_CHECK(EType, code) { \
bool exception_thrown = false; \
try { \
code; \
exception_thrown = true; \
} \
UASSERT(exception_thrown); \
-} while (0)
+}
class IGameDef;