45#include "timemory/backends/dmp.hpp"
55#if !defined(EXPECT_EQ)
56# define EXPECT_EQ(lhs, rhs) \
59 std::stringstream ss; \
60 ss << #lhs << " != " << #rhs << " @ line " << __LINE__ << " of " \
62 std::cerr << ss.str() << std::endl; \
63 throw std::runtime_error(ss.str()); \
67#if !defined(ASSERT_FALSE)
68# define ASSERT_FALSE(expr) \
71 std::stringstream ss; \
72 ss << "Expression: ( " << #expr << " ) " \
73 << "failed @ line " << __LINE__ << " of " << __FILE__; \
74 std::cerr << ss.str() << std::endl; \
75 throw std::runtime_error(ss.str()); \
79#if !defined(ASSERT_TRUE)
80# define ASSERT_TRUE(expr) \
83 std::stringstream ss; \
84 ss << "Expression: !( " << #expr << " ) " \
85 << "failed @ line " << __LINE__ << " of " << __FILE__; \
86 std::cerr << ss.str() << std::endl; \
87 throw std::runtime_error(ss.str()); \
95 if(tim::dmp::is_initialized())
96 ss <<
"[" << tim::dmp::rank() <<
"] ";
100#define rank_cout std::cout << rank_prefix()
103#define TEST_SUMMARY(argv_0, ntest_counter, nfail_counter) \
105 std::stringstream rank_sout; \
106 std::stringstream filler; \
108 filler << "#" << std::setw(78) << "" \
110 rank_sout << "\n... [\e[1;33mTESTING COMPLETED\e[0m] ... \n" << std::endl; \
111 rank_sout << filler.str() << "\n#\n"; \
113 << "[" << argv_0 << "] "; \
115 rank_sout << "\e[1;31mTESTS FAILED\e[0m: " << nfail_counter << '/' \
116 << ntest_counter << std::endl; \
118 rank_sout << "\e[1;36mTESTS PASSED\e[0m: " \
119 << (ntest_counter - nfail_counter) << '/' << ntest_counter \
121 rank_sout << "#\n" << filler.str() << "\n" << std::endl; \
122 rank_cout << rank_sout.str(); \
131#define CONFIGURE_TEST_SELECTOR(total_tests) \
132 int total_num_tests = total_tests; \
133 std::set<int> tests; \
135 for(int i = 0; i < total_tests; ++i) \
136 tests.insert(i + 1); \
137 for(int i = 1; i < argc; ++i) \
138 tests.insert(atoi(argv[i]));
155#define RUN_TEST(test_num, func, ntest_counter, nfail_counter) \
157 if(test_num > total_num_tests || tests.count(test_num) != 0) \
159 if(test_num > total_num_tests) \
160 printf("Warning! Test %i is greater than the specified number of " \
163 test_num, total_num_tests); \
166 ntest_counter += 1; \
168 } catch(std::exception & e) \
170 std::cerr << e.what() << std::endl; \
171 nfail_counter += 1; \
176 printf("\n... Skipping test #%i ...\n\n", test_num); \
tim::mpl::apply< std::string > string
std::string rank_prefix()