diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-19 22:23:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-19 22:23:47 +0200 |
commit | 88b436e6a9c98af7215bd115e1b7a3f1a1db99d3 (patch) | |
tree | f07cdd7f93ca26b84192d7b89f7b952e603ba5cf /src/unittest/test.h | |
parent | 7528986e4449febead9b18b6118f0b096f7cf800 (diff) | |
download | minetest-88b436e6a9c98af7215bd115e1b7a3f1a1db99d3.tar.gz minetest-88b436e6a9c98af7215bd115e1b7a3f1a1db99d3.tar.bz2 minetest-88b436e6a9c98af7215bd115e1b7a3f1a1db99d3.zip |
Code modernization: subfolders (#6283)
* Code modernization: subfolders
Modernize various code on subfolders client, network, script, threading, unittests, util
* empty function
* default constructor/destructor
* for range-based loops
* use emplace_back instead of push_back
* C++ STL header style
* Make connection.cpp readable in a pointed place + typo
Diffstat (limited to 'src/unittest/test.h')
-rw-r--r-- | src/unittest/test.h | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/unittest/test.h b/src/unittest/test.h index c4351a67b..44b0cd02b 100644 --- a/src/unittest/test.h +++ b/src/unittest/test.h @@ -31,7 +31,7 @@ class TestFailedException : public std::exception { }; // Runs a unit test and reports results -#define TEST(fxn, ...) do { \ +#define TEST(fxn, ...) { \ u64 t1 = porting::getTimeMs(); \ try { \ fxn(__VA_ARGS__); \ @@ -47,21 +47,20 @@ class TestFailedException : public std::exception { 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__); \ @@ -69,8 +68,7 @@ class TestFailedException : public std::exception { << " 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 { \ |