34 #define TEST(fxn, ...) { \
35 u64 t1 = porting::getTimeMs(); \
38 rawstream << "[PASS] "; \
39 } catch (TestFailedException &e) { \
40 rawstream << "[FAIL] "; \
42 } catch (std::exception &e) { \
43 rawstream << "Caught unhandled exception: " << e.what() << std::endl; \
44 rawstream << "[FAIL] "; \
48 u64 tdiff = porting::getTimeMs() - t1; \
49 rawstream << #fxn << " - " << tdiff << "ms" << std::endl; \
55 rawstream << "Test assertion failed: " #x << std::endl \
56 << " at " << fs::GetFilenameFromPath(__FILE__) \
57 << ":" << __LINE__ << std::endl; \
58 throw TestFailedException(); \
63 #define UTEST(x, fmt, ...) \
65 char utest_buf[1024]; \
66 snprintf(utest_buf, sizeof(utest_buf), fmt, __VA_ARGS__); \
67 rawstream << "Test assertion failed: " << utest_buf << std::endl \
68 << " at " << fs::GetFilenameFromPath(__FILE__) \
69 << ":" << __LINE__ << std::endl; \
70 throw TestFailedException(); \
74 #define UASSERTCMP(T, CMP, actual, expected) { \
79 << "Test assertion failed: " << #actual << " " << #CMP << " " \
80 << #expected << std::endl \
81 << " at " << fs::GetFilenameFromPath(__FILE__) << ":" \
82 << __LINE__ << std::endl \
83 << " actual: " << a << std::endl << " expected: " \
85 throw TestFailedException(); \
89 #define UASSERTEQ(T, actual, expected) UASSERTCMP(T, ==, actual, expected)
92 #define EXCEPTION_CHECK(EType, code) { \
93 bool exception_thrown = false; \
96 } catch (EType &e) { \
97 exception_thrown = true; \
99 UASSERT(exception_thrown); \
124 static std::vector<TestBase *> m_modules_to_test;
125 return m_modules_to_test;
u32 num_tests_run
Definition: test.h:114
std::string m_test_dir
Definition: test.h:117
std::string getTestTempDirectory()
Definition: test.cpp:321
bool testModule(IGameDef *gamedef)
Definition: test.cpp:301
virtual const char * getName()=0
std::string getTestTempFile()
Definition: test.cpp:336
virtual void runTests(IGameDef *gamedef)=0
u32 num_tests_failed
Definition: test.h:113
static void registerTestModule(TestBase *module)
Definition: test.h:128
static std::vector< TestBase * > & getTestModules()
Definition: test.h:122
u16 content_t
Definition: mapnode.h:28
content_t t_CONTENT_TORCH
Definition: test.cpp:33
content_t t_CONTENT_STONE
Definition: test.cpp:31
content_t t_CONTENT_BRICK
Definition: test.cpp:36
content_t t_CONTENT_WATER
Definition: test.cpp:34
content_t t_CONTENT_LAVA
Definition: test.cpp:35
bool run_tests()
Definition: test.cpp:258
content_t t_CONTENT_GRASS
Definition: test.cpp:32