Begin work on general NT validator

This commit is contained in:
Bruno Martins
2019-05-10 15:51:39 -04:00
committed by mdavidsaver
parent 2d186d40d5
commit b76c91a885
7 changed files with 439 additions and 262 deletions

View File

@ -72,6 +72,10 @@ TESTPROD_HOST += ntutilsTest
ntutilsTest_SRCS = ntutilsTest.cpp
TESTS += ntutilsTest
TESTPROD_HOST += ntvalidatorTest
ntutilsTest_SRCS = ntvalidatorTest.cpp
TESTS += ntvalidatorTest
TESTSCRIPTS_HOST += $(TESTS:%=%.t)
include $(TOP)/configure/RULES

37
test/ntvalidatorTest.cpp Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright information and license terms for this software can be
* found in the file LICENSE that is included with the distribution
*/
#include <epicsUnitTest.h>
#include <testMain.h>
#include <pv/ntvalidator.h>
#include <pv/ntndarray.h>
using namespace epics::nt;
using epics::pvData::StructureConstPtr;
using epics::pvData::Field;
void test_isCompatible()
{
testDiag("test_isCompatible");
StructureConstPtr ref(NTNDArray::createBuilder()->addAlarm()->createStructure());
Validator::Definition def;
def.structure = std::static_pointer_cast<const Field>(ref);
def.optional.insert(ref->getField("alarm").get());
StructureConstPtr struc(NTNDArray::createBuilder()->createStructure());
testOk1(Validator::isCompatible(def, struc));
}
MAIN(testNTValidator) {
testPlan(1);
test_isCompatible();
return testDone();
}