/** * Copyright - See the COPYRIGHT that is included with this distribution. * pvxs is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. */ #include #include #include #include namespace { using namespace pvxs; void testNTScalar() { testDiag("In %s", __func__); // plain, without display meta auto top = nt::NTScalar{TypeCode::Int32}.create(); testTrue(top.idStartsWith("epics:nt/NTScalar:"))<<"\n"<floatValue"] = shared_array({0.1, 0.2, 0.3, 0.4, 0.5}); testEq(top["value"].type(), TypeCode::Union); top = top["value"].lookup("->"); testEq(top.type(), TypeCode::Float32A); } void testNTURI() { testDiag("In %s", __func__); using namespace pvxs::members; auto def = nt::NTURI({ UInt32("arg1"), String("arg2"), }); auto top = def.call(42, "hello"); testTrue(top.idStartsWith("epics:nt/NTURI:"))<<"\n"<(), 42u); testEq(top["query.arg2"].as(), "hello"); } void testNTEnum() { testDiag("In %s", __func__); auto top = nt::NTEnum{}.create(); testTrue(top.idStartsWith("epics:nt/NTEnum:"))<<"\n"< labels({"Col A", "Col C", "Col B"}); testArrEq(top["labels"].as>(), labels); testTrue(top["value.A"].type()==TypeCode::Int32A); testTrue(top["value.B"].type()==TypeCode::StringA); std::vector names; for(auto fld : top["value"].ichildren()) { names.push_back(top.nameOf(fld)); } shared_array expect({"value.A", "value.C", "value.B"}); testArrEq(shared_array(names.begin(), names.end()), expect); } } // namespace MAIN(testnt) { testPlan(24); testNTScalar(); testNTNDArray(); testNTURI(); testNTEnum(); testNTTable(); return testDone(); }