From e0d422ffd9de9e01428bd9d19f17042985edf15a Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Tue, 28 May 2019 12:50:02 -0400 Subject: [PATCH] Validator: fix path handling and tests Makefile --- src/validator.h | 9 +++++---- test/Makefile | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/validator.h b/src/validator.h index 3a57344..4bc9196 100644 --- a/src/validator.h +++ b/src/validator.h @@ -11,7 +11,6 @@ #include - namespace epics { namespace nt { /** @@ -222,16 +221,18 @@ private: return *this; } + std::string fieldPath(path.empty() ? name : path + "." + name); + if (!field) { if (!optional) { result = Fail; - errors.push_back(Error(path + "." + name, Error::Type::MissingField)); + errors.push_back(Error(fieldPath, Error::Type::MissingField)); } } else if (!dynamic_cast(field.get())) { result = Fail; - errors.push_back(Error(path + "." + name, Error::Type::IncorrectType)); + errors.push_back(Error(fieldPath, Error::Type::IncorrectType)); } else if (check) { - Result r(field, path + "." + name); + Result r(field, fieldPath); *this |= check(r); } diff --git a/test/Makefile b/test/Makefile index b6535de..4b8ce72 100644 --- a/test/Makefile +++ b/test/Makefile @@ -73,7 +73,7 @@ ntutilsTest_SRCS = ntutilsTest.cpp TESTS += ntutilsTest TESTPROD_HOST += validatorTest -ntutilsTest_SRCS = validatorTest.cpp +validatorTest_SRCS = validatorTest.cpp TESTS += validatorTest TESTSCRIPTS_HOST += $(TESTS:%=%.t)