21 #include "flecsi/util/unit/output.hh" 26 inline log::devel_tag unit_tag(
"unit");
31 struct assert_handler_t;
37 error_stream_.str(std::string());
43 if(error_stream_.str().size()) {
44 std::stringstream stream;
45 stream << FLOG_OUTPUT_LTRED(
"TEST FAILED " << name_) << FLOG_COLOR_PLAIN
47 stream << error_stream_.str();
48 flog(utility) << stream.str();
51 flog(utility) << FLOG_OUTPUT_LTGREEN(
"TEST PASSED " << name_)
52 << FLOG_COLOR_PLAIN << std::endl;
60 const std::string & name()
const {
64 std::stringstream & stringstream() {
69 int operator->*(F f) {
80 std::stringstream error_stream_;
91 runtime_.result() = 1;
92 runtime_.stringstream()
93 << FLOG_OUTPUT_LTRED(
"ASSERT FAILED") <<
": assertion '" << condition
94 <<
"' failed in " << FLOG_OUTPUT_BROWN(file <<
":" << line)
95 << FLOG_COLOR_BROWN <<
" ";
99 runtime_.stringstream() << FLOG_COLOR_PLAIN << std::endl;
100 std::stringstream stream;
101 stream << FLOG_OUTPUT_LTRED(
"TEST FAILED " << runtime_.name())
102 << FLOG_COLOR_PLAIN << std::endl;
103 stream << runtime_.stringstream().str();
108 runtime_.stringstream() << value;
113 ::std::ostream & (*basic_manipulator)(::std::ostream & stream)) {
114 runtime_.stringstream() << basic_manipulator;
129 : runtime_(runtime) {
130 runtime_.result() = 1;
131 runtime_.stringstream()
132 << FLOG_OUTPUT_YELLOW(
"EXPECT FAILED") <<
": unexpected '" << condition
133 <<
"' occurred in " << FLOG_OUTPUT_BROWN(file <<
":" << line)
134 << FLOG_COLOR_BROWN <<
" ";
138 runtime_.stringstream() << FLOG_COLOR_PLAIN << std::endl;
143 runtime_.stringstream() << value;
148 ::std::ostream & (*basic_manipulator)(::std::ostream & stream)) {
149 runtime_.stringstream() << basic_manipulator;
158 template<
typename T1,
typename T2>
160 test_equal(
const T1 & v1,
const T2 & v2) {
164 template<
typename T1,
typename T2>
166 test_less(
const T1 & v1,
const T2 & v2) {
170 template<
typename T1,
typename T2>
172 test_greater(
const T1 & v1,
const T2 & v2) {
177 string_compare(
const char * lhs,
const char * rhs) {
179 return rhs ==
nullptr;
184 return strcmp(lhs, rhs) == 0;
188 string_case_compare(
const char * lhs,
const char * rhs) {
190 return rhs ==
nullptr;
195 return strcasecmp(lhs, rhs) == 0;
203 ::flecsi::log::flog_t::instance().config_stream().add_buffer( \ 204 "flog", std::clog, true); \ 205 ::flecsi::util::unit::state_t auto_unit_state(__func__); \ 206 return auto_unit_state->*[&]() -> void 208 #define UNIT_TYPE(name) ::flecsi::util::demangle((name)) 210 #define UNIT_TTYPE(type) ::flecsi::util::demangle(typeid(type).name()) 212 #define ASSERT_TRUE(condition) \ 216 return auto_unit_state >>= ::flecsi::util::unit::assert_handler_t( \ 217 #condition, __FILE__, __LINE__, auto_unit_state) 219 #define EXPECT_TRUE(condition) \ 223 ::flecsi::util::unit::expect_handler_t( \ 224 #condition, __FILE__, __LINE__, auto_unit_state) 226 #define ASSERT_FALSE(condition) \ 230 return auto_unit_state >>= ::flecsi::util::unit::assert_handler_t( \ 231 #condition, __FILE__, __LINE__, auto_unit_state) 233 #define EXPECT_FALSE(condition) \ 237 ::flecsi::util::unit::expect_handler_t( \ 238 #condition, __FILE__, __LINE__, auto_unit_state) 240 #define ASSERT_EQ(val1, val2) \ 241 ASSERT_TRUE(::flecsi::util::unit::test_equal((val1), (val2))) 243 #define EXPECT_EQ(val1, val2) \ 244 EXPECT_TRUE(::flecsi::util::unit::test_equal((val1), (val2))) 246 #define ASSERT_NE(val1, val2) \ 247 ASSERT_TRUE(!::flecsi::util::unit::test_equal((val1), (val2))) 249 #define EXPECT_NE(val1, val2) \ 250 EXPECT_TRUE(!::flecsi::util::unit::test_equal((val1), (val2))) 252 #define ASSERT_LT(val1, val2) \ 253 ASSERT_TRUE(::flecsi::util::unit::test_less((val1), (val2))) 255 #define EXPECT_LT(val1, val2) \ 256 EXPECT_TRUE(::flecsi::util::unit::test_less((val1), (val2))) 258 #define ASSERT_LE(val1, val2) \ 259 ASSERT_TRUE(::flecsi::util::unit::test_greater((val2), (val1))) 261 #define EXPECT_LE(val1, val2) \ 262 EXPECT_TRUE(::flecsi::util::unit::test_greater((val2), (val1))) 264 #define ASSERT_GT(val1, val2) \ 265 ASSERT_TRUE(::flecsi::util::unit::test_greater((val1), (val2))) 267 #define EXPECT_GT(val1, val2) \ 268 EXPECT_TRUE(::flecsi::util::unit::test_greater((val1), (val2))) 270 #define ASSERT_GE(val1, val2) \ 271 ASSERT_TRUE(::flecsi::util::unit::test_less((val2), (val1))) 273 #define EXPECT_GE(val1, val2) \ 274 EXPECT_TRUE(::flecsi::util::unit::test_less((val2), (val1))) 276 #define ASSERT_STREQ(str1, str2) \ 277 if(::flecsi::util::unit::string_compare(str1, str2)) \ 280 return auto_unit_state >>= ::flecsi::util::unit::assert_handler_t( \ 281 str1 " == " str2, __FILE__, __LINE__, auto_unit_state) 283 #define EXPECT_STREQ(str1, str2) \ 284 if(::flecsi::util::unit::string_compare(str1, str2)) \ 287 ::flecsi::util::unit::expect_handler_t( \ 288 str1 " == " str2, __FILE__, __LINE__, auto_unit_state) 290 #define ASSERT_STRNE(str1, str2) \ 291 if(!::flecsi::util::unit::string_compare(str1, str2)) \ 294 return auto_unit_state >>= ::flecsi::util::unit::assert_handler_t( \ 295 str1 " != " str2, __FILE__, __LINE__, auto_unit_state) 297 #define EXPECT_STRNE(str1, str2) \ 298 if(!::flecsi::util::unit::string_compare(str1, str2)) \ 301 ::flecsi::util::unit::expect_handler_t( \ 302 str1 " != " str2, __FILE__, __LINE__, auto_unit_state) 304 #define ASSERT_STRCASEEQ(str1, str2) \ 305 if(::flecsi::util::unit::string_case_compare(str1, str2)) \ 308 return auto_unit_state >>= ::flecsi::util::unit::assert_handler_t(str1 \ 309 " == " str2 " (case insensitive)", \ 314 #define EXPECT_STRCASEEQ(str1, str2) \ 315 if(::flecsi::util::unit::string_case_compare(str1, str2)) \ 318 ::flecsi::util::unit::expect_handler_t(str1 " == " str2 \ 319 " (case insensitive)", \ 324 #define ASSERT_STRCASENE(str1, str2) \ 325 if(!::flecsi::util::unit::string_case_compare(str1, str2)) \ 328 return auto_unit_state >>= ::flecsi::util::unit::assert_handler_t(str1 \ 329 " == " str2 " (case insensitive)", \ 334 #define EXPECT_STRCASENE(str1, str2) \ 335 if(!::flecsi::util::unit::string_case_compare(str1, str2)) \ 338 ::flecsi::util::unit::expect_handler_t(str1 " == " str2 \ 339 " (case insensitive)", \ 345 #define UNIT_CAPTURE() \ 346 ::flecsi::util::unit::test_output_t::instance().get_stream() 349 #define UNIT_DUMP() ::flecsi::util::unit::test_output_t::instance().get_buffer() 352 #define UNIT_EQUAL_BLESSED(f) \ 353 ::flecsi::util::unit::test_output_t::instance().equal_blessed((f)) 356 #define UNIT_WRITE(f) \ 357 ::flecsi::util::unit::test_output_t::instance().to_file((f)) 360 #if !defined(_MSC_VER) 361 #define UNIT_ASSERT(ASSERTION, ...) \ 362 ASSERT_##ASSERTION(__VA_ARGS__) << UNIT_DUMP() 365 #define UNIT_ASSERT(ASSERTION, x, y) ASSERT_##ASSERTION(x, y) << UNIT_DUMP() 369 #if !defined(_MSC_VER) 370 #define UNIT_EXPECT(EXPECTATION, ...) \ 371 EXPECT_##EXPECTATION(__VA_ARGS__) << UNIT_DUMP() 374 #define UNIT_EXPECT(EXPECTATION, x, y) EXPECT_##EXPECTATION(x, y) << UNIT_DUMP() 378 #define UNIT_CHECK_EQUAL_COLLECTIONS(...) \ 379 ::flecsi::util::unit::CheckEqualCollections(__VA_ARGS__) 381 #define UNIT_ASSERT_EQUAL_COLLECTIONS(...) \ 382 ASSERT_TRUE(::flecsi::util::unit::CheckEqualCollections(__VA_ARGS__) << UNIT_DUMP() 384 #define UNIT_EXPECT_EQUAL_COLLECTIONS(...) \ 385 EXPECT_TRUE(::flecsi::util::unit::CheckEqualCollections(__VA_ARGS__)) \
#define flog(severity)
Definition: flog.hh:136
std::ostream & operator<<(std::ostream &ostr, const filling_curve< D, T, DER > &k)
output for filling_curve using output_ function defined in the class
Definition: filling_curve.hh:206
Definition: control.hh:31