add Value::nameOf()

This commit is contained in:
Michael Davidsaver
2020-01-27 11:33:10 -08:00
parent 586e93b2d0
commit d4f4fe970d
3 changed files with 45 additions and 2 deletions
+17 -1
View File
@@ -445,11 +445,26 @@ void testAssign()
testOk1(!val["alarm"].isMarked(true, false));
}
void testName()
{
testDiag("%s", __func__);
auto def = nt::NTScalar{TypeCode::String}.build();
auto val = def.create();
testEq(val.nameOf(val["value"]), "value");
testEq(val.nameOf(val["alarm.status"]), "alarm.status");
testThrows<std::logic_error>([&val]() {
val.nameOf(val);
});
}
} // namespace
MAIN(testdata)
{
testPlan(67);
testPlan(70);
testSerialize1();
testDeserialize1();
testSimpleDef();
@@ -457,6 +472,7 @@ MAIN(testdata)
testDeserialize2();
testTraverse();
testAssign();
testName();
cleanup_for_valgrind();
return testDone();
}