From f2878195a6ffe1941c03c8ceabcb87ef6ed4dcb5 Mon Sep 17 00:00:00 2001
From: Wenqing Wang <wenqing.wang@ufz.de>
Date: Thu, 28 May 2020 16:38:57 +0200
Subject: [PATCH] [Tests] Assigned a namespace to readXML

---
 Tests/BaseLib/TestConfigTree.cpp              | 22 +++++++++----------
 .../TestCapillaryPressureSaturationModel.cpp  |  2 +-
 Tests/MaterialLib/TestFluidDensity.cpp        |  2 +-
 Tests/MaterialLib/TestFluidProperties.cpp     |  2 +-
 .../TestFluidSpecificHeatCapacityModel.cpp    |  2 +-
 .../TestFluidThermalConductivityModel.cpp     |  2 +-
 Tests/MaterialLib/TestFluidViscosity.cpp      |  2 +-
 Tests/MaterialLib/TestMPL.cpp                 |  5 +++--
 Tests/MaterialLib/TestPorousMediumStorage.cpp |  2 +-
 .../TestRelativePermeabilityModel.cpp         |  2 +-
 Tests/MathLib/TestLinearSolver.cpp            |  6 ++---
 Tests/MathLib/TestPiecewiseLinearCurve.cpp    |  2 +-
 Tests/NumLib/TestODEInt.cpp                   |  2 +-
 ...tTimeSteppingEvolutionaryPIDcontroller.cpp |  2 +-
 Tests/ParameterLib/Parameter.cpp              |  2 +-
 Tests/TestTools.cpp                           |  7 ++++--
 Tests/TestTools.h                             |  7 +++---
 17 files changed, 38 insertions(+), 33 deletions(-)

diff --git a/Tests/BaseLib/TestConfigTree.cpp b/Tests/BaseLib/TestConfigTree.cpp
index ff5568b9a97..c75db7edcb4 100644
--- a/Tests/BaseLib/TestConfigTree.cpp
+++ b/Tests/BaseLib/TestConfigTree.cpp
@@ -120,7 +120,7 @@ TEST(BaseLibConfigTree, Get)
             "<vector_bad1>x 1 2a</vector_bad1>"
             "<vector_bad2>0 1 2a</vector_bad2>"
             ;
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -256,7 +256,7 @@ TEST(BaseLibConfigTree, IncompleteParse)
             "<pt x=\"0.5\">1</pt>"
             "<pt2 x=\"0.5\" y=\"1.0\" z=\"2.0\" />"
             ;
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -297,7 +297,7 @@ TEST(BaseLibConfigTree, CheckRange)
             "<int>0</int>"
             "<int>1</int>"
             "<int>2</int>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -336,7 +336,7 @@ TEST(BaseLibConfigTree, GetSubtreeList)
             "<val><int>0</int></val>"
             "<val><int>1</int></val>"
             "<val><int>2</int></val>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -368,7 +368,7 @@ TEST(BaseLibConfigTree, GetParamList)
             "<int>2</int>"
             "<int2 a=\"b\">3</int2>"
             "<int3>4<error/></int3>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -419,7 +419,7 @@ TEST(BaseLibConfigTree, GetValueList)
             "<int>0</int>"
             "<int>1</int>"
             "<int>2</int>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -454,7 +454,7 @@ TEST(BaseLibConfigTree, NoConversion)
             "<ign/>"
             "<ign2/><ign2/><ign2/>"
             ;
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -506,7 +506,7 @@ TEST(BaseLibConfigTree, NoConversion)
 TEST(BaseLibConfigTree, BadKeynames)
 {
     const char xml[] = "";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -550,7 +550,7 @@ TEST(BaseLibConfigTree, StringLiterals)
     const char xml[] =
             "<s>test</s>"
             "<t>Test</t>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -576,7 +576,7 @@ TEST(BaseLibConfigTree, MoveConstruct)
             "<s>test</s>"
             "<t>Test</t>"
             "<u>data</u>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
@@ -620,7 +620,7 @@ TEST(BaseLibConfigTree, MoveAssign)
             "<s>test</s>"
             "<t>Test</t>"
             "<u>data</u>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     Callbacks cbs;
     {
diff --git a/Tests/MaterialLib/TestCapillaryPressureSaturationModel.cpp b/Tests/MaterialLib/TestCapillaryPressureSaturationModel.cpp
index 22824522f54..425953b2ff5 100644
--- a/Tests/MaterialLib/TestCapillaryPressureSaturationModel.cpp
+++ b/Tests/MaterialLib/TestCapillaryPressureSaturationModel.cpp
@@ -28,7 +28,7 @@ using namespace MaterialLib::PorousMedium;
 std::unique_ptr<CapillaryPressureSaturation> createCapillaryPressureModel(
     const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("capillary_pressure");
diff --git a/Tests/MaterialLib/TestFluidDensity.cpp b/Tests/MaterialLib/TestFluidDensity.cpp
index 9e459749b22..1b6bf024d91 100644
--- a/Tests/MaterialLib/TestFluidDensity.cpp
+++ b/Tests/MaterialLib/TestFluidDensity.cpp
@@ -28,7 +28,7 @@ using ArrayType = MaterialLib::Fluid::FluidProperty::ArrayType;
 // Test density models.
 std::unique_ptr<FluidProperty> createTestFluidDensityModel(const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("density");
diff --git a/Tests/MaterialLib/TestFluidProperties.cpp b/Tests/MaterialLib/TestFluidProperties.cpp
index a09d31572bb..8d41ff57eab 100644
--- a/Tests/MaterialLib/TestFluidProperties.cpp
+++ b/Tests/MaterialLib/TestFluidProperties.cpp
@@ -30,7 +30,7 @@ using ArrayType = MaterialLib::Fluid::FluidProperty::ArrayType;
 
 std::unique_ptr<FluidProperties> createTestFluidProperties(const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("fluid");
diff --git a/Tests/MaterialLib/TestFluidSpecificHeatCapacityModel.cpp b/Tests/MaterialLib/TestFluidSpecificHeatCapacityModel.cpp
index abb9d1e8af8..6beeed8cceb 100644
--- a/Tests/MaterialLib/TestFluidSpecificHeatCapacityModel.cpp
+++ b/Tests/MaterialLib/TestFluidSpecificHeatCapacityModel.cpp
@@ -30,7 +30,7 @@ using ArrayType = MaterialLib::Fluid::FluidProperty::ArrayType;
 std::unique_ptr<FluidProperty> createSpecificFluidHeatCapacityModel(
     const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("specific_heat_capacity");
diff --git a/Tests/MaterialLib/TestFluidThermalConductivityModel.cpp b/Tests/MaterialLib/TestFluidThermalConductivityModel.cpp
index 67b2e33cd72..eef10327548 100644
--- a/Tests/MaterialLib/TestFluidThermalConductivityModel.cpp
+++ b/Tests/MaterialLib/TestFluidThermalConductivityModel.cpp
@@ -31,7 +31,7 @@ using ArrayType = MaterialLib::Fluid::FluidProperty::ArrayType;
 std::unique_ptr<FluidProperty> createFluidThermalConductivityModel(
     const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("thermal_conductivity");
diff --git a/Tests/MaterialLib/TestFluidViscosity.cpp b/Tests/MaterialLib/TestFluidViscosity.cpp
index 3130935ec4e..6a7bef22790 100644
--- a/Tests/MaterialLib/TestFluidViscosity.cpp
+++ b/Tests/MaterialLib/TestFluidViscosity.cpp
@@ -27,7 +27,7 @@ using ArrayType = MaterialLib::Fluid::FluidProperty::ArrayType;
 
 std::unique_ptr<FluidProperty> createTestViscosityModel(const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("viscosity");
diff --git a/Tests/MaterialLib/TestMPL.cpp b/Tests/MaterialLib/TestMPL.cpp
index 0dcb8795121..7ed654f1689 100644
--- a/Tests/MaterialLib/TestMPL.cpp
+++ b/Tests/MaterialLib/TestMPL.cpp
@@ -18,12 +18,13 @@
 #include "MaterialLib/MPL/CreateMedium.h"
 #include "MathLib/InterpolationAlgorithms/PiecewiseLinearInterpolation.h"
 #include "ParameterLib/Parameter.h"
+#include "Tests/TestTools.h"
 
 namespace Tests
 {
 std::unique_ptr<MPL::Medium> createTestMaterial(std::string const& xml)
 {
-    auto const ptree = readXml(xml.c_str());
+    auto const ptree = Tests::readXml(xml.c_str());
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& config = conf.getConfigSubtree("medium");
@@ -41,7 +42,7 @@ std::unique_ptr<MaterialPropertyLib::Property> createTestProperty(
         BaseLib::ConfigTree const& config)>
         createProperty)
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("property");
diff --git a/Tests/MaterialLib/TestPorousMediumStorage.cpp b/Tests/MaterialLib/TestPorousMediumStorage.cpp
index 29bdda8b84f..bc475ed885c 100644
--- a/Tests/MaterialLib/TestPorousMediumStorage.cpp
+++ b/Tests/MaterialLib/TestPorousMediumStorage.cpp
@@ -24,7 +24,7 @@ using namespace MaterialLib::PorousMedium;
 
 std::unique_ptr<Storage> createTestStorageModel(const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("storage");
diff --git a/Tests/MaterialLib/TestRelativePermeabilityModel.cpp b/Tests/MaterialLib/TestRelativePermeabilityModel.cpp
index e69e43900b8..b4cae71a6f2 100644
--- a/Tests/MaterialLib/TestRelativePermeabilityModel.cpp
+++ b/Tests/MaterialLib/TestRelativePermeabilityModel.cpp
@@ -28,7 +28,7 @@ using namespace MaterialLib::PorousMedium;
 std::unique_ptr<RelativePermeability> createRelativePermeabilityModel(
     const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("relative_permeability");
diff --git a/Tests/MathLib/TestLinearSolver.cpp b/Tests/MathLib/TestLinearSolver.cpp
index 417b49f512d..b0a5cf497cc 100644
--- a/Tests/MathLib/TestLinearSolver.cpp
+++ b/Tests/MathLib/TestLinearSolver.cpp
@@ -283,7 +283,7 @@ TEST(MPITest_Math, CheckInterface_PETSc_Linear_Solver_basic)
             "  </parameters>"
             "  <prefix>ptest1</prefix>"
             "</petsc>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     checkLinearSolverInterface<MathLib::PETScMatrix,
                                MathLib::PETScVector,
@@ -317,7 +317,7 @@ TEST(MPITest_Math, CheckInterface_PETSc_Linear_Solver_chebyshev_sor)
             "  </parameters>"
             "  <prefix>ptest2</prefix>"
             "</petsc>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     checkLinearSolverInterface<MathLib::PETScMatrix,
                                MathLib::PETScVector,
@@ -353,7 +353,7 @@ TEST(MPITest_Math, CheckInterface_PETSc_Linear_Solver_gmres_amg)
             "  </parameters>"
             "  <prefix>ptest3</prefix>"
             "</petsc>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
 
     checkLinearSolverInterface<MathLib::PETScMatrix,
                                MathLib::PETScVector,
diff --git a/Tests/MathLib/TestPiecewiseLinearCurve.cpp b/Tests/MathLib/TestPiecewiseLinearCurve.cpp
index 750cbaaaf42..37bcef80f91 100644
--- a/Tests/MathLib/TestPiecewiseLinearCurve.cpp
+++ b/Tests/MathLib/TestPiecewiseLinearCurve.cpp
@@ -24,7 +24,7 @@
 template <typename CurveType>
 std::unique_ptr<CurveType> createPiecewiseLinearCurve(const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("curve");
diff --git a/Tests/NumLib/TestODEInt.cpp b/Tests/NumLib/TestODEInt.cpp
index c216470fe0d..1e7e4467aa1 100644
--- a/Tests/NumLib/TestODEInt.cpp
+++ b/Tests/NumLib/TestODEInt.cpp
@@ -41,7 +41,7 @@ createLinearSolver()
         "<petsc><parameters>"
         "-ksp_type bcgs -pc_type sor -ksp_rtol 1e-24 -ksp_max_it 100 -ksp_initial_guess_nonzero false"
         "</parameters></petsc>";
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree config(ptree, "", BaseLib::ConfigTree::onerror,
                                BaseLib::ConfigTree::onwarning);
     return std::make_unique<GlobalLinearSolver>("", &config);
diff --git a/Tests/NumLib/TestTimeSteppingEvolutionaryPIDcontroller.cpp b/Tests/NumLib/TestTimeSteppingEvolutionaryPIDcontroller.cpp
index 74d297a3c4b..81f00799763 100644
--- a/Tests/NumLib/TestTimeSteppingEvolutionaryPIDcontroller.cpp
+++ b/Tests/NumLib/TestTimeSteppingEvolutionaryPIDcontroller.cpp
@@ -25,7 +25,7 @@
 std::unique_ptr<NumLib::TimeStepAlgorithm> createTestTimeStepper(
     const char xml[])
 {
-    auto const ptree = readXml(xml);
+    auto const ptree = Tests::readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
     auto const& sub_config = conf.getConfigSubtree("time_stepping");
diff --git a/Tests/ParameterLib/Parameter.cpp b/Tests/ParameterLib/Parameter.cpp
index ababafa72d2..b35966abb1d 100644
--- a/Tests/ParameterLib/Parameter.cpp
+++ b/Tests/ParameterLib/Parameter.cpp
@@ -35,7 +35,7 @@ std::unique_ptr<Parameter<double>> constructParameterFromString(
              std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> const&
         curves = {})
 {
-    auto const xml_ptree = readXml(xml.c_str());
+    auto const xml_ptree = Tests::readXml(xml.c_str());
     BaseLib::ConfigTree config_tree(xml_ptree, "", BaseLib::ConfigTree::onerror,
                                     BaseLib::ConfigTree::onwarning);
     auto parameter_base = createParameter(config_tree, meshes, curves);
diff --git a/Tests/TestTools.cpp b/Tests/TestTools.cpp
index ae7772f8b58..98ff64c9484 100644
--- a/Tests/TestTools.cpp
+++ b/Tests/TestTools.cpp
@@ -11,8 +11,9 @@
 
 #include "Tests/TestTools.h"
 
-boost::property_tree::ptree
-readXml(const char xml[])
+namespace Tests
+{
+boost::property_tree::ptree readXml(const char xml[])
 {
     boost::property_tree::ptree ptree;
     std::istringstream xml_str(xml);
@@ -22,3 +23,5 @@ readXml(const char xml[])
         boost::property_tree::xml_parser::trim_whitespace);
     return ptree;
 }
+
+}  // namespace Tests
diff --git a/Tests/TestTools.h b/Tests/TestTools.h
index 6a9bce301c5..f15110466d9 100644
--- a/Tests/TestTools.h
+++ b/Tests/TestTools.h
@@ -24,6 +24,7 @@
 #define ASSERT_ARRAY_EQ(E,A,N)\
     for (std::size_t i=0; i<(unsigned)(N); i++) \
         ASSERT_EQ((E)[i], (A)[i]);
-
-boost::property_tree::ptree
-readXml(const char xml[]);
+namespace Tests
+{
+boost::property_tree::ptree readXml(const char xml[]);
+}  // namespace Tests
-- 
GitLab