From 6a9aae469bae8595535239d01c79c22c7adee5f8 Mon Sep 17 00:00:00 2001
From: Christoph Lehmann <christoph.lehmann@ufz.de>
Date: Tue, 8 Mar 2016 11:25:03 +0100
Subject: [PATCH] [T] extracted common testing functionality

---
 Tests/BaseLib/TestConfigTree.cpp | 13 +------------
 Tests/TestTools.cpp              | 24 ++++++++++++++++++++++++
 Tests/TestTools.h                |  4 ++++
 3 files changed, 29 insertions(+), 12 deletions(-)
 create mode 100644 Tests/TestTools.cpp

diff --git a/Tests/BaseLib/TestConfigTree.cpp b/Tests/BaseLib/TestConfigTree.cpp
index 726747bcd6e..c97ed98083a 100644
--- a/Tests/BaseLib/TestConfigTree.cpp
+++ b/Tests/BaseLib/TestConfigTree.cpp
@@ -14,6 +14,7 @@
 #include <sstream>
 
 #include "BaseLib/ConfigTree.h"
+#include "Tests/TestTools.h"
 
 // make useful line numbers appear in the output of gtest
 #define EXPECT_ERR_WARN(cbs, error, warning) do  { \
@@ -73,18 +74,6 @@ private:
     bool _warning = false;
 };
 
-
-boost::property_tree::ptree
-readXml(const char xml[])
-{
-    boost::property_tree::ptree ptree;
-    std::istringstream xml_str(xml);
-    read_xml(xml_str, ptree,
-             boost::property_tree::xml_parser::no_comments |
-             boost::property_tree::xml_parser::trim_whitespace);
-    return ptree;
-}
-
 BaseLib::ConfigTree
 makeConfigTree(boost::property_tree::ptree const& ptree, Callbacks& cbs)
 {
diff --git a/Tests/TestTools.cpp b/Tests/TestTools.cpp
new file mode 100644
index 00000000000..2d5078e539f
--- /dev/null
+++ b/Tests/TestTools.cpp
@@ -0,0 +1,24 @@
+/**
+ * \copyright
+ * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
+ *            Distributed under a Modified BSD License.
+ *              See accompanying file LICENSE.txt or
+ *              http://www.opengeosys.org/project/license
+ *
+ */
+
+#include <boost/property_tree/xml_parser.hpp>
+
+#include "TestTools.h"
+
+boost::property_tree::ptree
+readXml(const char xml[])
+{
+    boost::property_tree::ptree ptree;
+    std::istringstream xml_str(xml);
+    boost::property_tree::read_xml(
+        xml_str, ptree,
+        boost::property_tree::xml_parser::no_comments |
+        boost::property_tree::xml_parser::trim_whitespace);
+    return ptree;
+}
diff --git a/Tests/TestTools.h b/Tests/TestTools.h
index 36b060d8fe3..5afa28a1354 100644
--- a/Tests/TestTools.h
+++ b/Tests/TestTools.h
@@ -13,6 +13,7 @@
  */
 
 #include <gtest/gtest.h>
+#include <boost/property_tree/ptree_fwd.hpp>
 
 #ifndef TESTTOOLS_H_
 #define TESTTOOLS_H_
@@ -25,4 +26,7 @@
     for (std::size_t i=0; i<(unsigned)(N); i++) \
         ASSERT_EQ((E)[i], (A)[i]);
 
+boost::property_tree::ptree
+readXml(const char xml[]);
+
 #endif // TESTTOOLS_H_
-- 
GitLab