void assert_not_null(const T *a, const std::string &msg, int line, const char *file) { if (a == 0) { // throw exception std::stringstream msgstr; msgstr << "FAILURE at " << file << ":" << line << ": value " << a << " is null: " << msg; throw unit_exception(msgstr.str()); } }
void unit_test::assert_true(bool a, const std::string &msg, int line, const char *file) { ++current_test_func_info->assertion_count; if (!a) { std::stringstream msgstr; msgstr << "FAILURE at " << file << ":" << line << ": value " << a << " is false: " << msg; throw unit_exception(msgstr.str()); } }
void assert_less(const T &a, const T &b, const std::string &msg, int line, const char *file) { if (a >= b) { // throw exception std::stringstream msgstr; msgstr << "FAILURE at " << file << ":" << line << ": value " << a << " is greater equal " << b << ": " << msg; throw unit_exception(msgstr.str()); } }
void assert_greater(const X &a, const Y &b, const std::string &msg, int line, const char *file) { if (a <= b) { // throw exception std::stringstream msgstr; msgstr << "FAILURE at " << file << ":" << line << ": value " << a << " is not greater " << b << ": " << msg; throw unit_exception(msgstr.str()); } }
void assert_equal(const char *a, const char *b, const std::string &msg, int line, const char *file) { if (strcmp(a, b) != 0) { // throw exception std::stringstream msgstr; msgstr << "FAILURE at " << file << ":" << line << ": value " << a << " is not equal " << b << ": " << msg; throw unit_exception(msgstr.str()); } }
void assert_equal(const X &a, const bool &b, const std::string &msg, int line, const char *file) { bool cmp = a > 0; if (cmp != b) { // throw exception std::stringstream msgstr; msgstr << "FAILURE at " << file << ":" << line << ": value " << a << " is not equal " << b << ": " << msg; throw unit_exception(msgstr.str()); } }
void unit_test::error(const std::string &msg, int line, const char *file) { std::stringstream msgstr; msgstr << "FAILURE at " << file << ":" << line << ": " << msg; throw unit_exception(msgstr.str()); }