diff options
Diffstat (limited to 'lib/common/Test.h')
-rw-r--r-- | lib/common/Test.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/common/Test.h b/lib/common/Test.h index 08ba4542..a09a64af 100644 --- a/lib/common/Test.h +++ b/lib/common/Test.h @@ -51,6 +51,7 @@ extern std::string bbackupd_args, bbstored_args, bbackupquery_args, test_args; #define TEST_THAT_ABORTONFAIL(condition) {if(!(condition)) TEST_ABORT_WITH_MESSAGE("Condition [" #condition "] failed")} // NOTE: The 0- bit is to allow this to work with stuff which has negative constants for flags (eg ConnectionException) +<<<<<<< HEAD #define TEST_CHECK_THROWS(statement, excepttype, subtype) \ { \ bool didthrow = false; \ @@ -76,6 +77,35 @@ extern std::string bbackupd_args, bbstored_args, bbackupquery_args, test_args; { \ TEST_FAIL_WITH_MESSAGE("Didn't throw exception " #excepttype "(" #subtype ")") \ } \ +======= +#define TEST_CHECK_THROWS(statement, excepttype, subtype) \ + { \ + bool didthrow = false; \ + HideExceptionMessageGuard hide; \ + BOX_TRACE("Exception logging disabled at " __FILE__ ":" \ + << __LINE__); \ + try \ + { \ + statement; \ + } \ + catch(excepttype &e) \ + { \ + if(e.GetSubType() != ((unsigned int)excepttype::subtype) \ + && e.GetSubType() != (unsigned int)(0-excepttype::subtype)) \ + { \ + throw; \ + } \ + didthrow = true; \ + } \ + catch(...) \ + { \ + throw; \ + } \ + if(!didthrow) \ + { \ + TEST_FAIL_WITH_MESSAGE("Didn't throw exception " #excepttype "(" #subtype ")") \ + } \ +>>>>>>> 0.12 } // utility macro for comparing two strings in a line @@ -91,7 +121,11 @@ extern std::string bbackupd_args, bbstored_args, bbackupquery_args, test_args; \ if(_exp_str != _found_str) \ { \ +<<<<<<< HEAD BOX_WARNING("Expected <" << _exp_str << "> but found <" << \ +======= + BOX_ERROR("Expected <" << _exp_str << "> but found <" << \ +>>>>>>> 0.12 _found_str << ">"); \ \ std::ostringstream _oss3; \ @@ -127,20 +161,34 @@ extern std::string bbackupd_args, bbstored_args, bbackupquery_args, test_args; } \ } +<<<<<<< HEAD +======= +>>>>>>> 0.12 // utility macro for testing a line #define TEST_LINE(_condition, _line) \ TEST_THAT(_condition); \ if (!(_condition)) \ { \ +<<<<<<< HEAD printf("Test failed on <%s>\n", _line.c_str()); \ +======= + std::ostringstream _ossl; \ + _ossl << _line; \ + std::string _line_str = _ossl.str(); \ + printf("Test failed on <%s>\n", _line_str.c_str()); \ +>>>>>>> 0.12 } bool TestFileExists(const char *Filename); bool TestDirExists(const char *Filename); // -1 if doesn't exist +<<<<<<< HEAD int TestGetFileSize(const char *Filename); +======= +int TestGetFileSize(const std::string& Filename); +>>>>>>> 0.12 std::string ConvertPaths(const std::string& rOriginal); int RunCommand(const std::string& rCommandLine); bool ServerIsAlive(int pid); |