19 template<
class C,
void (C::*M)()>
23 testDiag(
"------- %s::%s --------", kname, mname);
26 }
catch(std::exception& e) {
28 testAbort(
"unexpected exception: %s", e.what());
34 std::ostringstream strm;
35 const bool dotest, pass;
54 template<
typename LHS,
typename RHS>
57 return testPassx(l==r)<<nLHS<<
" ("<<l<<
") == "<<nRHS<<
" ("<<r<<
")";
60 template<
typename LHS,
typename RHS>
63 return testPassx(l!=r)<<nLHS<<
" ("<<l<<
") != "<<nRHS<<
" ("<<r<<
")";
98 #define TEST_METHOD(klass, method) ::detail::test_method<klass, &klass::method>(#klass, #method) 110 #define testEqual(LHS, RHS) ::detail::testEqualx(#LHS, #RHS, LHS, RHS) 112 #define testNotEqual(LHS, RHS) ::detail::testNotEqualx(#LHS, #RHS, LHS, RHS) 124 #define testTrue(B) ::detail::testPassx(!!(B))<<#B 132 #define testThrows(EXC, CODE) try{ CODE; testFail("unexpected success of " #CODE); }catch(EXC& e){testPass("catch expected exception: %s", e.what());} 140 #define testShow() ::detail::testPassx() 149 template<
typename PVD>
151 testFieldEqual(
const std::tr1::shared_ptr<const epics::pvData::PVStructure>& val,
const char *name,
typename PVD::value_type expect)
154 return ::detail::testPassx(
false)<<
" null structure pointer";
156 typename PVD::const_shared_pointer fval(val->getSubField<PVD>(name));
160 fval = uval->get<PVD>();
163 return ::detail::testPassx(
false)<<
" field '"<<name<<
"' with type "<<
typeid(PVD).name()<<
" does not exist";
165 typename PVD::value_type actual(fval->get());
166 return ::detail::testPassx(actual==expect)<<name<<
" ("<<actual<<
") == "<<expect;
170 template<
typename PVD>
172 testFieldEqual(
const std::tr1::shared_ptr<const epics::pvData::PVStructure>& val,
const char *name,
typename PVD::const_svector expect)
175 return ::detail::testPassx(
false)<<
" null structure pointer";
177 typename PVD::const_shared_pointer fval(val->getSubField<PVD>(name));
179 return ::detail::testPassx(
false)<<
" field '"<<name<<
"' with type "<<
typeid(PVD).name()<<
" does not exist";
181 typename PVD::const_svector actual(fval->view());
182 return ::detail::testPassx(actual==expect)<<name<<
" ("<<actual<<
") == "<<expect;
188 #endif // PVUNITTEST_H
void test_method(const char *kname, const char *mname)
testPassx testNotEqualx(const char *nLHS, const char *nRHS, const LHS &l, const RHS &r)
int testDiag(const char *fmt,...)
#define PRINT_EXCEPTION(EI)
void testAbort(const char *fmt,...)
PVUnion has a single subfield.
testPassx & operator<<(const T &v)
testPassx testEqualx(const char *nLHS, const char *nRHS, const LHS &l, const RHS &r)
::detail::testPassx testFieldEqual(const std::tr1::shared_ptr< const epics::pvData::PVStructure > &val, const char *name, typename PVD::value_type expect)