From: Marcin Siodelski Date: Wed, 27 Mar 2019 19:11:28 +0000 (+0100) Subject: [#490,!284] Renamed ElementExtractor to ElementValue. X-Git-Tag: Kea-1.6.0-beta~297 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a0af2500b163ee0396ff9d2f5590e75252c23a2;p=thirdparty%2Fkea.git [#490,!284] Renamed ElementExtractor to ElementValue. Per review comments. --- diff --git a/src/lib/cc/Makefile.am b/src/lib/cc/Makefile.am index 3f98f79adf..134b62c5d0 100644 --- a/src/lib/cc/Makefile.am +++ b/src/lib/cc/Makefile.am @@ -6,7 +6,7 @@ AM_CXXFLAGS = $(KEA_CXXFLAGS) lib_LTLIBRARIES = libkea-cc.la libkea_cc_la_SOURCES = data.cc data.h -libkea_cc_la_SOURCES += element_extractor.h +libkea_cc_la_SOURCES += element_value.h libkea_cc_la_SOURCES += cfg_to_element.h dhcp_config_error.h libkea_cc_la_SOURCES += command_interpreter.cc command_interpreter.h libkea_cc_la_SOURCES += json_feed.cc json_feed.h @@ -29,7 +29,7 @@ libkea_cc_include_HEADERS = \ command_interpreter.h \ data.h \ dhcp_config_error.h \ - element_extractor.h \ + element_value.h \ json_feed.h \ simple_parser.h \ stamped_element.h \ diff --git a/src/lib/cc/element_extractor.h b/src/lib/cc/element_value.h similarity index 87% rename from src/lib/cc/element_extractor.h rename to src/lib/cc/element_value.h index ac8158ff1f..964fd0ee92 100644 --- a/src/lib/cc/element_extractor.h +++ b/src/lib/cc/element_value.h @@ -4,8 +4,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef ELEMENT_EXTRACTOR_H -#define ELEMENT_EXTRACTOR_H +#ifndef ELEMENT_VALUE_H +#define ELEMENT_VALUE_H #include #include @@ -39,7 +39,7 @@ namespace data { /// /// @tparam T Type of the value to be extracted. template -class ElementExtractor { +class ElementValue { public: /// @brief Function operator extracting an @c Element value as @@ -51,9 +51,9 @@ public: } }; -/// @brief The @c ElementExtractor specialization for double. +/// @brief The @c ElementValue specialization for double. template<> -class ElementExtractor { +class ElementValue { public: /// @brief Function operator extracting an @c Element value as @@ -65,9 +65,9 @@ public: } }; -/// @brief The @c ElementExtractor specialization for boolean. +/// @brief The @c ElementValue specialization for boolean. template<> -class ElementExtractor { +class ElementValue { public: /// @brief Function operator extracting an @c Element value as @@ -80,9 +80,9 @@ public: }; -/// @brief The @c ElementExtractor specialization for string. +/// @brief The @c ElementValue specialization for string. template<> -class ElementExtractor { +class ElementValue { public: /// @brief Function operator extracting an @c Element value as @@ -97,4 +97,4 @@ public: } // end of namespace isc::data } // end of namespace isc -#endif // ELEMENT_EXTRACTOR_H +#endif // ELEMENT_VALUE_H diff --git a/src/lib/cc/tests/Makefile.am b/src/lib/cc/tests/Makefile.am index 2682c5a15d..31a5d5e25d 100644 --- a/src/lib/cc/tests/Makefile.am +++ b/src/lib/cc/tests/Makefile.am @@ -17,7 +17,7 @@ TESTS += run_unittests run_unittests_SOURCES = command_interpreter_unittests.cc run_unittests_SOURCES += data_unittests.cc run_unittests_SOURCES += data_file_unittests.cc -run_unittests_SOURCES += element_extractor_unittests.cc +run_unittests_SOURCES += element_value_unittests.cc run_unittests_SOURCES += json_feed_unittests.cc run_unittests_SOURCES += simple_parser_unittest.cc run_unittests_SOURCES += stamped_element_unittest.cc diff --git a/src/lib/cc/tests/element_extractor_unittests.cc b/src/lib/cc/tests/element_extractor_unittests.cc deleted file mode 100644 index da327a41c4..0000000000 --- a/src/lib/cc/tests/element_extractor_unittests.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC") -// -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#include -#include -#include - -using namespace isc::data; - -namespace { - -// This test verifies that integer value can be extracted. -TEST(ElementExtractor, intValue) { - EXPECT_EQ(5, ElementExtractor()(Element::create(5))); - EXPECT_THROW(ElementExtractor()(Element::create("hola!")), - TypeError); -} - -// This test verifies that double value can be extracted. -TEST(ElementExtractor, doubleValue) { - EXPECT_EQ(1.4, ElementExtractor()(Element::create(1.4))); - EXPECT_THROW(ElementExtractor()(Element::create("hola!")), - TypeError); -} - -// This test verifies that boolean value can be extracted. -TEST(ElementExtractor, boolValue) { - EXPECT_TRUE(ElementExtractor()(Element::create(true))); - EXPECT_THROW(ElementExtractor()(Element::create("hola!")), - TypeError); -} - -// This test verifies that string value can be extracted. -TEST(ElementExtractor, stringValue) { - EXPECT_EQ("hola!", ElementExtractor()(Element::create("hola!"))); - EXPECT_THROW(ElementExtractor()(Element::create(false)), - TypeError); -} - -} diff --git a/src/lib/cc/tests/element_value_unittests.cc b/src/lib/cc/tests/element_value_unittests.cc new file mode 100644 index 0000000000..e284440636 --- /dev/null +++ b/src/lib/cc/tests/element_value_unittests.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2019 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include +#include +#include + +using namespace isc::data; + +namespace { + +// This test verifies that integer value can be extracted. +TEST(ElementValue, intValue) { + EXPECT_EQ(5, ElementValue()(Element::create(5))); + EXPECT_THROW(ElementValue()(Element::create("hola!")), + TypeError); +} + +// This test verifies that double value can be extracted. +TEST(ElementValue, doubleValue) { + EXPECT_EQ(1.4, ElementValue()(Element::create(1.4))); + EXPECT_THROW(ElementValue()(Element::create("hola!")), + TypeError); +} + +// This test verifies that boolean value can be extracted. +TEST(ElementValue, boolValue) { + EXPECT_TRUE(ElementValue()(Element::create(true))); + EXPECT_THROW(ElementValue()(Element::create("hola!")), + TypeError); +} + +// This test verifies that string value can be extracted. +TEST(ElementValue, stringValue) { + EXPECT_EQ("hola!", ElementValue()(Element::create("hola!"))); + EXPECT_THROW(ElementValue()(Element::create(false)), + TypeError); +} + +} diff --git a/src/lib/dhcpsrv/network.h b/src/lib/dhcpsrv/network.h index 9a0f8701be..1793baf81b 100644 --- a/src/lib/dhcpsrv/network.h +++ b/src/lib/dhcpsrv/network.h @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include @@ -28,9 +28,9 @@ namespace isc { namespace data { -/// @brief The @c ElementExtractor specialization for IOAddress. +/// @brief The @c ElementValue specialization for IOAddress. template<> -class ElementExtractor { +class ElementValue { public: /// @brief Function operator extracting an @c Element value as @@ -519,7 +519,7 @@ protected: if (global_param) { // If there is a global parameter, convert it to the // optional value of the given type and return. - return (data::ElementExtractor()(global_param)); + return (data::ElementValue()(global_param)); } } }