mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Fixed bug with function getMultipleValuesFromConfig and added test which confirms this.
This commit is contained in:
parent
326dab83d9
commit
26d9ee3ae5
@ -24,7 +24,7 @@ std::vector<std::string> getMultipleValuesFromConfig(const Poco::Util::AbstractC
|
||||
{
|
||||
std::vector<std::string> 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;
|
||||
}
|
||||
|
||||
|
26
dbms/src/Common/tests/gtest_getMultipleValuesFromConfig.cpp
Normal file
26
dbms/src/Common/tests/gtest_getMultipleValuesFromConfig.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include <Common/getMultipleKeysFromConfig.h>
|
||||
#include <Poco/AutoPtr.h>
|
||||
#include <Poco/Util/XMLConfiguration.h>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
using namespace DB;
|
||||
|
||||
TEST(Common, getMultipleValuesFromConfig)
|
||||
{
|
||||
std::istringstream xml_isteam(R"END(<?xml version="1.0"?>
|
||||
<yandex>
|
||||
<first_level>
|
||||
<second_level>0</second_level>
|
||||
<second_level>1</second_level>
|
||||
<second_level>2</second_level>
|
||||
<second_level>3</second_level>
|
||||
</first_level>
|
||||
</yandex>)END");
|
||||
|
||||
Poco::AutoPtr<Poco::Util::XMLConfiguration> config = new Poco::Util::XMLConfiguration(xml_isteam);
|
||||
std::vector<std::string> answer = getMultipleValuesFromConfig(*config, "first_level", "second_level");
|
||||
std::vector<std::string> right_answer = {"0", "1", "2", "3"};
|
||||
EXPECT_EQ(answer, right_answer);
|
||||
}
|
Loading…
Reference in New Issue
Block a user