/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * 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.
*
* GROMACS is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* \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
// TODO: Only add this option to those test binaries that actually need it
// (depending on the linker, it may or may not appear right now),
// or replace by a generic mechanism in TestReferenceData.
+//! \cond
GMX_TEST_OPTIONS(StringTestOptions, options)
{
options->addOption(
.store(&g_bWriteToStdOut)
.description("Print the test string to stdout instead of checking against reference data"));
}
+//! \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)
{
}
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);
}