Remove gmx::File (except for File::exists())
[alexxy/gromacs.git] / src / testutils / stringtest.cpp
index 586cb9f1832569f040c7446fac20b0e1a544fbe9..ce37bdfee5f873631851795b37dd32500df8ea05 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \ingroup module_testutils
  */
-#include "testutils/stringtest.h"
+#include "gmxpre.h"
+
+#include "stringtest.h"
+
+#include <string>
+
+#include <boost/scoped_ptr.hpp>
 
 #include "gromacs/options/basicoptions.h"
 #include "gromacs/options/options.h"
-#include "gromacs/utility/file.h"
+#include "gromacs/utility/textreader.h"
 
+#include "testutils/refdata.h"
 #include "testutils/testoptions.h"
 
 namespace gmx
@@ -71,7 +78,38 @@ GMX_TEST_OPTIONS(StringTestOptions, options)
 }
 //! \endcond
 
+/********************************************************************
+ * StringTestBase::Impl
+ */
+
+class StringTestBase::Impl
+{
+    public:
+        TestReferenceData                           data_;
+        boost::scoped_ptr<TestReferenceChecker>     checker_;
+};
+
+/********************************************************************
+ * StringTestBase
+ */
+
+// static
+void StringTestBase::checkText(TestReferenceChecker *checker,
+                               const std::string &text, const char *id)
+{
+    if (g_bWriteToStdOut)
+    {
+        printf("%s:\n", id);
+        printf("%s[END]\n", text.c_str());
+    }
+    else
+    {
+        checker->checkStringBlock(text, id);
+    }
+}
+
 StringTestBase::StringTestBase()
+    : impl_(new Impl)
 {
 }
 
@@ -82,31 +120,23 @@ StringTestBase::~StringTestBase()
 TestReferenceChecker &
 StringTestBase::checker()
 {
-    if (checker_.get() == NULL)
+    if (!impl_->checker_)
     {
-        checker_.reset(new TestReferenceChecker(data_.rootChecker()));
+        impl_->checker_.reset(new TestReferenceChecker(impl_->data_.rootChecker()));
     }
-    return *checker_;
+    return *impl_->checker_;
 }
 
 void
 StringTestBase::checkText(const std::string &text, const char *id)
 {
-    if (g_bWriteToStdOut)
-    {
-        printf("%s:\n", id);
-        printf("%s[END]\n", text.c_str());
-    }
-    else
-    {
-        checker().checkStringBlock(text, id);
-    }
+    checkText(&checker(), text, id);
 }
 
 void
 StringTestBase::checkFileContents(const std::string &filename, const char *id)
 {
-    std::string text = File::readToString(filename);
+    const std::string text = TextReader::readFileToString(filename);
     checkText(text, id);
 }