From f036b2c7bdff83b61070d4fb61833f5b5099b738 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Wed, 30 Mar 2016 20:05:53 +0000 Subject: [PATCH] [T] Add ConfigTree test for reading vector values. --- Tests/BaseLib/TestConfigTree.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Tests/BaseLib/TestConfigTree.cpp b/Tests/BaseLib/TestConfigTree.cpp index c97ed98083a..71259e6b7a8 100644 --- a/Tests/BaseLib/TestConfigTree.cpp +++ b/Tests/BaseLib/TestConfigTree.cpp @@ -11,7 +11,9 @@ #include <logog/include/logog.hpp> #include <boost/property_tree/xml_parser.hpp> +#include <numeric> #include <sstream> +#include <vector> #include "BaseLib/ConfigTree.h" #include "Tests/TestTools.h" @@ -114,6 +116,7 @@ TEST(BaseLibConfigTree, Get) "</sub>" "<x>Y</x>" "<z attr=\"0.5\" optattr=\"false\">32.0</z>" + "<vector>0 1 2 3 4</vector>" ; auto const ptree = readXml(xml); @@ -219,6 +222,17 @@ TEST(BaseLibConfigTree, Get) EXPECT_FALSE(z.getConfAttributeOptional<bool>("also_not_an_attr")); // nonexisting attribute EXPECT_ERR_WARN(cbs, false, false); } + + // Testing vector + { + auto v = conf.getConfParam<std::vector<int>>("vector"); + EXPECT_ERR_WARN(cbs, false, false); + EXPECT_EQ(5u, v.size()); + std::vector<int> expected_vector(5); + std::iota(expected_vector.begin(), expected_vector.end(), 0); + EXPECT_TRUE(std::equal(expected_vector.begin(), + expected_vector.end(), v.begin())); + } EXPECT_ERR_WARN(cbs, false, false); } // ConfigTree destroyed here EXPECT_ERR_WARN(cbs, false, false); -- GitLab