Commit 574215ed authored by Davis King's avatar Davis King

Added DLIB_TEST and DLIB_TEST_MSG macros to the testing suite

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402974
parent 168a862d
......@@ -11,6 +11,25 @@ namespace test
static dlib::mutex spinner_mutex;
// -----------------------------------------------------------------------------
void check_test (
bool _exp,
long line,
const char* file,
const char* _exp_str
)
{
if ( !(_exp) )
{
std::ostringstream dlib__out;
dlib__out << "\n\nError occurred at line " << line << ".\n";
dlib__out << "Error occurred in file " << file << ".\n";
dlib__out << "Failing expression was " << _exp_str << ".\n";
throw dlib::error(dlib__out.str());
}
}
// -----------------------------------------------------------------------------
map_of_testers& testers (
......
......@@ -17,6 +17,18 @@
#endif
#define DLIB_TEST(_exp) check_test(_exp, __LINE__, __FILE__, #_exp);
#define DLIB_TEST_MSG(_exp,_message) \
{if ( !(_exp) ) \
{ \
std::ostringstream dlib__out; \
dlib__out << "\n\nError occurred at line " << __LINE__ << ".\n"; \
dlib__out << "Error occurred in file " << __FILE__ << ".\n"; \
dlib__out << "Failing expression was " << #_exp << ".\n"; \
dlib__out << _message << "\n"; \
throw dlib::error(dlib__out.str()); \
}}
namespace test
{
......@@ -26,6 +38,15 @@ namespace test
map_of_testers& testers (
);
// -----------------------------------------------------------------------------
void check_test (
bool _exp,
long line,
const char* file,
const char* _exp_str
);
// -----------------------------------------------------------------------------
void print_spinner (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment