39 #define POTHOS_TEST_BLOCK(path, name) \ 
   40 struct name : Pothos::TestingBase \ 
   42     void runTestsImpl(void); \ 
   43     void runTestsImpl_(void); \ 
   45 pothos_static_block(name) \ 
   47     std::shared_ptr<Pothos::TestingBase> testObj(new name()); \ 
   48     Pothos::PluginRegistry::add(Pothos::Plugin( \ 
   49         Pothos::PluginPath(path).join(#name), Pothos::Object(testObj))); \ 
   51 void name::runTestsImpl(void) \ 
   53     POTHOS_TEST_CHECKPOINT(); \ 
   54     this->runTestsImpl_(); \ 
   56 void name::runTestsImpl_(void) 
   59 #define POTHOS_TEST_CHECKPOINT() \ 
   60     Pothos::TestingBase::current().report("checkpoint", "", "", __LINE__, __FILE__) 
   63 #define __POTHOS_TEST_STATEMENT(message, statement) \ 
   65     Pothos::TestingBase::current().report(message, #statement, "", __LINE__, __FILE__); \ 
   67     catch(const std::string &ex){Pothos::TestingBase::current().report(message, #statement, ex, __LINE__, __FILE__);} \ 
   68     catch(const Pothos::Exception &ex){Pothos::TestingBase::current().report(message, #statement, ex.displayText(), __LINE__, __FILE__);} \ 
   69     catch(const std::exception &ex){Pothos::TestingBase::current().report(message, #statement, ex.what(), __LINE__, __FILE__);} \ 
   70     catch(...){Pothos::TestingBase::current().report(message, #statement, "unknown", __LINE__, __FILE__);} \ 
   74 #define __POTHOS_TEST_ASSERT(message, statement) \ 
   76     __POTHOS_TEST_STATEMENT(message, if (statement) {} else throw std::string("statement \"" #statement "\" evaluated false");); \ 
   80 #define POTHOS_TEST_TRUE(statement) \ 
   82     __POTHOS_TEST_ASSERT(#statement, statement) \ 
   86 #define POTHOS_TEST_EQUAL(lhs, rhs) \ 
   88     __POTHOS_TEST_ASSERT(Pothos::TestingBase::current().toString(lhs) + \ 
   89         " == " + Pothos::TestingBase::current().toString(rhs), (lhs) == (rhs)); \ 
   93 #define POTHOS_TEST_EQUALV(lhs, rhs) \ 
   95     POTHOS_TEST_EQUAL((lhs).size(), (rhs).size()); \ 
   96     for (size_t i = 0; i < (lhs).size(); i++) \ 
   98         __POTHOS_TEST_ASSERT( \ 
   99             "index " + Pothos::TestingBase::current().toString(i) + \ 
  100             " asserts " + Pothos::TestingBase::current().toString((lhs)[i]) + \ 
  101             " == " + Pothos::TestingBase::current().toString((rhs)[i]), (lhs)[i] == (rhs)[i]); \ 
  106 #define POTHOS_TEST_THROWS(statement, expectedException) \ 
  108     Pothos::TestingBase::current().report(#statement, #statement, "", __LINE__, __FILE__); \ 
  109     __POTHOS_TEST_STATEMENT(#statement " must throw " #expectedException, \ 
  110         try{statement;throw std::string("statement \"" #statement "\" did not throw");} \ 
  111         catch(const expectedException &){}); \ 
  120     static TestingBase ¤t(
void);
 
  122     virtual void runTestsImpl() = 0;
 
  124         const std::string &message,
 
  125         const std::string &statement,
 
  126         const std::string &error,
 
  128         const std::string &file);
 
  129     template <
typename T>
 
  132         std::stringstream ss;
 
#define POTHOS_API
Definition: Config.hpp:41
 
Definition: Testing.hpp:116
 
std::string toString(const T &v)
Definition: Testing.hpp:130