add pvUnitTest.h

This commit is contained in:
Michael Davidsaver
2017-07-06 17:05:30 +02:00
parent a0210af5c6
commit 919bc0138a
8 changed files with 246 additions and 2 deletions

View File

@@ -0,0 +1,51 @@
/*
* Copyright information and license terms for this software can be
* found in the file LICENSE that is included with the distribution
*/
#include <stdexcept>
#include <testMain.h>
#include <pv/pvUnitTest.h>
#include <pv/valueBuilder.h>
namespace pvd = epics::pvData;
namespace {
struct MyTest {
MyTest() { testPass("MyTest::MyTest"); }
~MyTest() { testPass("MyTest::~MyTest"); }
void test1() { testPass("test1"); }
void test2() { testPass("test2"); }
};
}//namespace
MAIN(testUnitTest)
{
testPlan(0);
try {
TEST_METHOD(MyTest, test1);
TEST_METHOD(MyTest, test2);
{
std::string x("hello");
testEqual(x, "hello");
testEqual(x, "hello")<<" Extra";
}
pvd::PVStructurePtr S(pvd::ValueBuilder()
.addNested("alarm")
.add<pvd::pvInt>("severity", 1)
.add<pvd::pvString>("message", "hello")
.endNested()
.buildPVStructure());
testFieldEqual<pvd::PVInt>(S, "alarm.severity", 1);
testFieldEqual<pvd::PVString>(S, "alarm.message", "hello")<<" More";
}catch(std::exception& e){
testAbort("Unhandled exception: %s", e.what());
}
return testDone();
}