Skip to content

Commit 0a2c039

Browse files
-cleared containers before populating them with new values;
-set version to 3.2.0;
1 parent 8a668e8 commit 0a2c039

File tree

6 files changed

+38
-2
lines changed

6 files changed

+38
-2
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.18)
2-
project(figcone VERSION 3.1.0)
2+
project(figcone VERSION 3.2.0)
33
include(external/seal_lake)
44

55
SealLake_IsInstallEnabled(INSTALL_FIGCONE_TREE)

include/figcone/detail/dict.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class Dict : public INode {
3838
{
3939
hasValue_ = true;
4040
position_ = node.position();
41+
dictMap_ = {};
4142
if (!node.isItem())
4243
throw ConfigError{"Dictionary '" + name_ + "': config node can't be a list.", node.position()};
4344
if constexpr (sfun::is_optional_v<TMap>)
4445
dictMap_.emplace();
45-
maybeOptValue(dictMap_).clear();
4646

4747
for (const auto& paramName : node.asItem().paramNames()) {
4848
const auto& paramValue = node.asItem().param(paramName);

include/figcone/detail/nodelist.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class NodeList : public detail::INode {
4242
{
4343
hasValue_ = true;
4444
position_ = nodeList.position();
45+
nodeList_ = {};
4546
if (!nodeList.isList())
4647
throw ConfigError{"Node list '" + name_ + "': config node must be a list.", nodeList.position()};
4748
if constexpr (sfun::is_optional<TCfgList>::value)

include/figcone/detail/paramlist.h

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class ParamList : public IParam {
3838
{
3939
position_ = paramList.position();
4040
hasValue_ = true;
41+
paramListValue_ = {};
4142
if constexpr (sfun::is_optional_v<TParamList>)
4243
paramListValue_.emplace();
4344

tests/test_paramlist.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,21 @@ TEST(TestParamList, DefaultValue)
406406
EXPECT_EQ(cfg.testIntList.at(2), 3);
407407
}
408408

409+
TEST(TestParamList, OverwriteDefaultValue)
410+
{
411+
///testStrList = []
412+
///
413+
auto tree = figcone::makeTreeRoot();
414+
tree->asItem().addParamList("testStrList", std::vector<std::string>{}, {1, 1});
415+
tree->asItem().addParamList("testIntList", std::vector<std::string>{"42", "43"}, {1, 1});
416+
auto parser = TreeProvider{std::move(tree)};
417+
auto cfgReader = figcone::ConfigReader{figcone::NameFormat::CamelCase};
418+
auto cfg = cfgReader.read<CfgStr>("", parser);
419+
420+
ASSERT_EQ(cfg.testStrList.size(), 0);
421+
ASSERT_EQ(cfg.testIntList.size(), 2);
422+
EXPECT_EQ(cfg.testIntList.at(0), 42);
423+
EXPECT_EQ(cfg.testIntList.at(1), 43);
424+
}
425+
409426
} //namespace test_paramlist

tests_static_refl/test_paramlist_cpp20.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,21 @@ TEST(StaticReflTestParamList, DefaultValue)
266266
EXPECT_EQ(cfg.testIntList.at(2), 3);
267267
}
268268

269+
TEST(TestParamList, OverwriteDefaultValue)
270+
{
271+
///testStrList = []
272+
///
273+
auto tree = figcone::makeTreeRoot();
274+
tree->asItem().addParamList("testStrList", std::vector<std::string>{}, {1, 1});
275+
tree->asItem().addParamList("testIntList", std::vector<std::string>{"42", "43"}, {1, 1});
276+
auto parser = TreeProvider{std::move(tree)};
277+
auto cfgReader = figcone::ConfigReader{figcone::NameFormat::CamelCase};
278+
auto cfg = cfgReader.read<CfgStr>("", parser);
279+
280+
ASSERT_EQ(cfg.testStrList.size(), 0);
281+
ASSERT_EQ(cfg.testIntList.size(), 2);
282+
EXPECT_EQ(cfg.testIntList.at(0), 42);
283+
EXPECT_EQ(cfg.testIntList.at(1), 43);
284+
}
285+
269286
} //namespace test_paramlist

0 commit comments

Comments
 (0)