38 #define POTHOS_TEST_BLOCK(path, name) \ 39 POTHOS_STATIC_FIXTURE_DECL void name ## Runner(void); \ 40 template <Pothos::Detail::InitFcn runner> \ 41 struct name : Pothos::TestingBase \ 43 void runTestsImpl(void) \ 45 POTHOS_TEST_CHECKPOINT(); \ 49 pothos_static_block(name) \ 51 std::shared_ptr<Pothos::TestingBase> testObj(new name<name ## Runner>()); \ 52 Pothos::PluginRegistry::add(Pothos::Plugin( \ 53 Pothos::PluginPath(path).join(#name), Pothos::Object(testObj))); \ 55 POTHOS_STATIC_FIXTURE_DECL void name ## Runner(void) 58 #define POTHOS_TEST_CHECKPOINT() \ 59 Pothos::TestingBase::current().report("checkpoint", "", "", __LINE__, __FILE__) 62 #define __POTHOS_TEST_STATEMENT(message, statement) \ 64 Pothos::TestingBase::current().report(message, #statement, "", __LINE__, __FILE__); \ 66 catch(const std::string &ex){Pothos::TestingBase::current().report(message, #statement, ex, __LINE__, __FILE__);} \ 67 catch(const Pothos::Exception &ex){Pothos::TestingBase::current().report(message, #statement, ex.displayText(), __LINE__, __FILE__);} \ 68 catch(const std::exception &ex){Pothos::TestingBase::current().report(message, #statement, ex.what(), __LINE__, __FILE__);} \ 69 catch(...){Pothos::TestingBase::current().report(message, #statement, "unknown", __LINE__, __FILE__);} \ 73 #define __POTHOS_TEST_ASSERT(message, statement) \ 75 __POTHOS_TEST_STATEMENT(message, if (statement) {} else throw std::string("statement \"" #statement "\" evaluated false");); \ 79 #define POTHOS_TEST_TRUE(statement) \ 81 __POTHOS_TEST_ASSERT("assert true " #statement, statement); \ 85 #define POTHOS_TEST_EQUAL(lhs, rhs) \ 87 __POTHOS_TEST_ASSERT( \ 88 "assert equal " + Pothos::TestingBase::current().toString(lhs) + \ 89 " == " + Pothos::TestingBase::current().toString(rhs), (lhs) == (rhs)); \ 93 #define POTHOS_TEST_CLOSE(lhs, rhs, tol) \ 95 __POTHOS_TEST_ASSERT( \ 96 "assert close " + Pothos::TestingBase::current().toString(lhs) + \ 97 " ~= " + Pothos::TestingBase::current().toString(rhs), (std::abs((lhs) - (rhs)) <= (tol))); \ 101 #define POTHOS_TEST_EQUALV(lhs, rhs) \ 103 POTHOS_TEST_EQUAL((lhs).size(), (rhs).size()); \ 104 for (size_t i = 0; i < (lhs).size(); i++) \ 106 __POTHOS_TEST_ASSERT( \ 107 "index " + Pothos::TestingBase::current().toString(i) + \ 108 " asserts " + Pothos::TestingBase::current().toString((lhs)[i]) + \ 109 " == " + Pothos::TestingBase::current().toString((rhs)[i]), (lhs)[i] == (rhs)[i]); \ 114 #define POTHOS_TEST_EQUALA(lhs, rhs, size) \ 116 for (size_t i = 0; i < (size); i++) \ 118 __POTHOS_TEST_ASSERT( \ 119 "index " + Pothos::TestingBase::current().toString(i) + \ 120 " asserts " + Pothos::TestingBase::current().toString((lhs)[i]) + \ 121 " == " + Pothos::TestingBase::current().toString((rhs)[i]), (lhs)[i] == (rhs)[i]); \ 126 #define POTHOS_TEST_THROWS(statement, expectedException) \ 128 Pothos::TestingBase::current().report(#statement, #statement, "", __LINE__, __FILE__); \ 129 __POTHOS_TEST_STATEMENT(#statement " must throw " #expectedException, \ 130 try{statement;throw std::string("statement \"" #statement "\" did not throw");} \ 131 catch(const expectedException &){}); \ 140 static TestingBase ¤t(
void);
142 virtual void runTestsImpl() = 0;
144 const std::string &message,
145 const std::string &statement,
146 const std::string &error,
148 const std::string &file);
149 template <
typename T>
#define POTHOS_API
Definition: Config.hpp:41
std::string toString(void) const
Definition: Testing.hpp:134
Definition: Object.hpp:55
Definition: Testing.hpp:136
std::string toString(const T &v)
Definition: Testing.hpp:150