From eef8bd4fba3d8f6eaf36250ba35910a04d012299 Mon Sep 17 00:00:00 2001 From: dhickin Date: Fri, 22 Aug 2014 23:24:47 +0100 Subject: [PATCH] NTNDArray. Added unit test. --- test/nt/Makefile | 4 +++ test/nt/ntndarrayTest.cpp | 57 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 test/nt/ntndarrayTest.cpp diff --git a/test/nt/Makefile b/test/nt/Makefile index 7cab6d4..fdf08bb 100644 --- a/test/nt/Makefile +++ b/test/nt/Makefile @@ -24,6 +24,10 @@ TESTPROD_HOST += nttableTest nttableTest_SRCS = nttableTest.cpp TESTS += nttableTest +TESTPROD_HOST += ntndarrayTest +ntndarrayTest_SRCS = ntndarrayTest.cpp +TESTS += ntndarrayTest + TESTSCRIPTS_HOST += $(TESTS:%=%.t) include $(TOP)/configure/RULES diff --git a/test/nt/ntndarrayTest.cpp b/test/nt/ntndarrayTest.cpp new file mode 100644 index 0000000..62e564e --- /dev/null +++ b/test/nt/ntndarrayTest.cpp @@ -0,0 +1,57 @@ +/** + * Copyright - See the COPYRIGHT that is included with this distribution. + * EPICS pvDataCPP is distributed subject to a Software License Agreement found + * in file LICENSE that is included with this distribution. + */ + +#include +#include + +#include + +using namespace epics::nt; +using namespace epics::pvData; +using std::tr1::dynamic_pointer_cast; + +void test_builder() +{ + testDiag("test_builder"); + + NTNDArrayBuilderPtr builder = NTNDArray::createBuilder(); + testOk(builder.get() != 0, "Got builder"); + + StructureConstPtr structure = builder-> + addDescriptor()-> + addTimeStamp()-> + addAlarm()-> + addDisplay()-> + createStructure(); + testOk1(structure.get() != 0); + if (!structure) + return; + + testOk1(NTNDArray::is_a(structure)); + testOk1(structure->getID() == NTNDArray::URI); + testOk1(structure->getField("value").get() != 0); + testOk1(structure->getField("compressedSize").get() != 0); + testOk1(structure->getField("uncompressedSize").get() != 0); + testOk1(structure->getField("codec").get() != 0); + testOk1(structure->getField("dimension").get() != 0); + testOk1(structure->getField("uniqueId").get() != 0); + testOk1(structure->getField("dataTimeStamp").get() != 0); + testOk1(structure->getField("attribute").get() != 0); + testOk1(structure->getField("descriptor").get() != 0); + testOk1(structure->getField("alarm").get() != 0); + testOk1(structure->getField("timeStamp").get() != 0); + testOk1(structure->getField("display").get() != 0); + std::cout << *structure << std::endl; + +} + +MAIN(testNTNDArray) { + testPlan(16); + test_builder(); + return testDone(); +} + +