Skip to content

Commit

Permalink
-cleared containers before populating them with new values;
Browse files Browse the repository at this point in the history
-set figcone_xml version to v1.2.0;
-set version to 3.2.0;
  • Loading branch information
kamchatka-volcano committed Oct 4, 2024
1 parent 8a668e8 commit 1907a19
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.18)
project(figcone VERSION 3.1.0)
project(figcone VERSION 3.2.0)
include(external/seal_lake)

SealLake_IsInstallEnabled(INSTALL_FIGCONE_TREE)
Expand Down Expand Up @@ -101,7 +101,7 @@ if (FIGCONE_USE_ALL OR FIGCONE_USE_JSON OR FIGCONE_USE_YAML OR FIGCONE_USE_TOML
figcone::figcone_formats
)
SealLake_AddDependencies(
figcone_formats 1.1.0
figcone_formats 1.2.0
)
endif ()

Expand Down
6 changes: 3 additions & 3 deletions formats/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project(figcone_formats VERSION 1.1.0)
project(figcone_formats VERSION 1.2.0)

option(FIGCONE_USE_ALL "Enable all supported config formats" ON)
option(FIGCONE_USE_JSON "Enable JSON config format" OFF)
Expand Down Expand Up @@ -64,9 +64,9 @@ endif()

if(FIGCONE_USE_ALL OR FIGCONE_USE_XML)
SealLake_Import(
figcone_xml 1.1.0
figcone_xml 1.2.0
GIT_REPOSITORY https://github.com/kamchatka-volcano/figcone_xml.git
GIT_TAG v1.1.0
GIT_TAG v1.2.0
)
SealLake_Copy(
WILDCARDS ${figcone_xml_SOURCE_DIR}/include/figcone_xml/*
Expand Down
2 changes: 1 addition & 1 deletion include/figcone/detail/dict.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class Dict : public INode {
{
hasValue_ = true;
position_ = node.position();
dictMap_ = {};
if (!node.isItem())
throw ConfigError{"Dictionary '" + name_ + "': config node can't be a list.", node.position()};
if constexpr (sfun::is_optional_v<TMap>)
dictMap_.emplace();
maybeOptValue(dictMap_).clear();

for (const auto& paramName : node.asItem().paramNames()) {
const auto& paramValue = node.asItem().param(paramName);
Expand Down
1 change: 1 addition & 0 deletions include/figcone/detail/nodelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class NodeList : public detail::INode {
{
hasValue_ = true;
position_ = nodeList.position();
nodeList_ = {};
if (!nodeList.isList())
throw ConfigError{"Node list '" + name_ + "': config node must be a list.", nodeList.position()};
if constexpr (sfun::is_optional<TCfgList>::value)
Expand Down
1 change: 1 addition & 0 deletions include/figcone/detail/paramlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ParamList : public IParam {
{
position_ = paramList.position();
hasValue_ = true;
paramListValue_ = {};
if constexpr (sfun::is_optional_v<TParamList>)
paramListValue_.emplace();

Expand Down
17 changes: 17 additions & 0 deletions tests/test_paramlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,21 @@ TEST(TestParamList, DefaultValue)
EXPECT_EQ(cfg.testIntList.at(2), 3);
}

TEST(TestParamList, OverwriteDefaultValue)
{
///testStrList = []
///
auto tree = figcone::makeTreeRoot();
tree->asItem().addParamList("testStrList", std::vector<std::string>{}, {1, 1});
tree->asItem().addParamList("testIntList", std::vector<std::string>{"42", "43"}, {1, 1});
auto parser = TreeProvider{std::move(tree)};
auto cfgReader = figcone::ConfigReader{figcone::NameFormat::CamelCase};
auto cfg = cfgReader.read<CfgStr>("", parser);

ASSERT_EQ(cfg.testStrList.size(), 0);
ASSERT_EQ(cfg.testIntList.size(), 2);
EXPECT_EQ(cfg.testIntList.at(0), 42);
EXPECT_EQ(cfg.testIntList.at(1), 43);
}

} //namespace test_paramlist
17 changes: 17 additions & 0 deletions tests_static_refl/test_paramlist_cpp20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,21 @@ TEST(StaticReflTestParamList, DefaultValue)
EXPECT_EQ(cfg.testIntList.at(2), 3);
}

TEST(TestParamList, OverwriteDefaultValue)
{
///testStrList = []
///
auto tree = figcone::makeTreeRoot();
tree->asItem().addParamList("testStrList", std::vector<std::string>{}, {1, 1});
tree->asItem().addParamList("testIntList", std::vector<std::string>{"42", "43"}, {1, 1});
auto parser = TreeProvider{std::move(tree)};
auto cfgReader = figcone::ConfigReader{figcone::NameFormat::CamelCase};
auto cfg = cfgReader.read<CfgStr>("", parser);

ASSERT_EQ(cfg.testStrList.size(), 0);
ASSERT_EQ(cfg.testIntList.size(), 2);
EXPECT_EQ(cfg.testIntList.at(0), 42);
EXPECT_EQ(cfg.testIntList.at(1), 43);
}

} //namespace test_paramlist

0 comments on commit 1907a19

Please sign in to comment.