The open source OpenXR runtime
at prediction-2 33 lines 1.0 kB view raw
1#ifndef _TESTING_H_ 2#define _TESTING_H_ 1 3 4// Standard Dependencies 5#include <iostream> 6#include <iomanip> 7 8#ifdef ASSERT 9# undef ASSERT 10#endif 11 12/** Run the test with the given name. */ 13#define RUN_TEST(TestName) { \ 14 bool __test_result = true; \ 15 std::cout << "Executing test " << std::left << std::setw(40) << #TestName; \ 16 TestName(__test_result); \ 17 std::cout << "=> " << (__test_result ? "Success" : "Fail") << std::endl; \ 18} 19 20/** Define a test with the given name. */ 21#define TEST(TestName) \ 22 void TestName(bool& __test_result) 23 24/** Ensures the given condition passes for the test to pass. */ 25#define ASSERT(condition) { \ 26 if (!(condition)) { \ 27 __test_result = false; \ 28 return; \ 29 } \ 30} 31 32#endif // _TESTING_H_ 33