more test

This commit is contained in:
Michael Davidsaver
2016-01-29 15:01:37 -05:00
parent f081e10c62
commit 3cd09efa0a
4 changed files with 135 additions and 23 deletions

View File

@@ -64,6 +64,12 @@ struct TestMonitor {
test1_y = 2;
}
~TestMonitor()
{
client->destroy();
gateway->destroy(); // noop atm.
}
void test_event()
{
testDiag("Push the initial event through from upstream to downstream");
@@ -82,6 +88,10 @@ struct TestMonitor {
testOk1(elem && elem->pvStructurePtr->getSubFieldT<pvd::PVInt>("x")->get()==1);
if(elem) mon->release(elem);
testOk1(!!mon->poll());
mon->destroy();
}
void test_share()
@@ -119,24 +129,38 @@ struct TestMonitor {
if(elem) mon->release(elem);
if(elem2) mon2->release(elem2);
testOk1(!!mon->poll());
testOk1(!!mon2->poll());
testDiag("explicitly push an update");
test1_x = 42;
test1_y = 43;
pvd::BitSet changed;
changed.set(1); // only indicate that 'x' changed
test1->post(changed);
elem = mon->poll();
elem2 = mon2->poll();
testOk1(!!elem.get());
testOk1(!!elem2.get());
testOk1(elem!=elem2);
testOk1(elem && elem->pvStructurePtr->getSubFieldT<pvd::PVInt>("x")->get()==42);
testOk1(elem && elem->pvStructurePtr->getSubFieldT<pvd::PVInt>("y")->get()==2);
testOk1(elem2 && elem2->pvStructurePtr->getSubFieldT<pvd::PVInt>("x")->get()==42);
testOk1(elem2 && elem2->pvStructurePtr->getSubFieldT<pvd::PVInt>("y")->get()==2);
if(elem) mon->release(elem);
if(elem2) mon2->release(elem2);
testOk1(!!mon->poll());
testOk1(!!mon2->poll());
mon->destroy();
mon2->destroy();
}
};
template<class C, void (C::*M)()>
void test_method(const char *kname, const char *mname)
{
try {
testDiag("------- %s::%s --------", kname, mname);
C inst;
(inst.*M)();
} catch(std::exception& e) {
PRINT_EXCEPTION(e);
testAbort("unexpected exception: %s", e.what());
}
}
#define TEST_METHOD(klass, method) test_method<klass, &klass::method>(#klass, #method)
} // namespace
MAIN(testmon)
@@ -144,5 +168,6 @@ MAIN(testmon)
testPlan(0);
TEST_METHOD(TestMonitor, test_event);
TEST_METHOD(TestMonitor, test_share);
TestProvider::testCounts();
return testDone();
}