From 26d9ee3ae5a2fefe5bc85b7aee4be6c11e20f5bb Mon Sep 17 00:00:00 2001 From: millb Date: Thu, 17 Oct 2019 19:52:47 +0300 Subject: [PATCH] Fixed bug with function getMultipleValuesFromConfig and added test which confirms this. --- dbms/src/Common/getMultipleKeysFromConfig.cpp | 2 +- .../gtest_getMultipleValuesFromConfig.cpp | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 dbms/src/Common/tests/gtest_getMultipleValuesFromConfig.cpp diff --git a/dbms/src/Common/getMultipleKeysFromConfig.cpp b/dbms/src/Common/getMultipleKeysFromConfig.cpp index fa50d82adab..ecad5cc45eb 100644 --- a/dbms/src/Common/getMultipleKeysFromConfig.cpp +++ b/dbms/src/Common/getMultipleKeysFromConfig.cpp @@ -24,7 +24,7 @@ std::vector getMultipleValuesFromConfig(const Poco::Util::AbstractC { std::vector values; for (const auto & key : DB::getMultipleKeysFromConfig(config, root, name)) - values.emplace_back(config.getString(key)); + values.emplace_back(config.getString(root.empty() ? key : root + "." + key)); return values; } diff --git a/dbms/src/Common/tests/gtest_getMultipleValuesFromConfig.cpp b/dbms/src/Common/tests/gtest_getMultipleValuesFromConfig.cpp new file mode 100644 index 00000000000..3d0802db251 --- /dev/null +++ b/dbms/src/Common/tests/gtest_getMultipleValuesFromConfig.cpp @@ -0,0 +1,26 @@ +#include +#include +#include + +#include + + +using namespace DB; + +TEST(Common, getMultipleValuesFromConfig) +{ + std::istringstream xml_isteam(R"END( + + + 0 + 1 + 2 + 3 + +)END"); + + Poco::AutoPtr config = new Poco::Util::XMLConfiguration(xml_isteam); + std::vector answer = getMultipleValuesFromConfig(*config, "first_level", "second_level"); + std::vector right_answer = {"0", "1", "2", "3"}; + EXPECT_EQ(answer, right_answer); +} \ No newline at end of file