1 #ifndef MARISA_ASSERT_H_ 2 #define MARISA_ASSERT_H_ 3 4 #include <iostream> 5 #include <cstdlib> 6 7 #define ASSERT(cond) (void)((!!(cond)) || \ 8 ((std::cout << __LINE__ << ": Assertion `" << #cond << "' failed." \ 9 << std::endl), std::exit(-1), 0)) 10 11 #define EXCEPT(code, expected_error_code) try { \ 12 code; \ 13 std::cout << __LINE__ << ": Exception `" << #code << "' failed." \ 14 << std::endl; \ 15 std::exit(-1); \ 16 } catch (const marisa::Exception &ex) { \ 17 ASSERT(ex.error_code() == expected_error_code); \ 18 } 19 20 #define TEST_START() \ 21 (std::cout << __FILE__ << ":" << __LINE__ << ": " << __FUNCTION__ << "(): ") 22 23 #define TEST_END() \ 24 (std::cout << "ok" << std::endl) 25 26 #endif // MARISA_ASSERT_H_ 27