3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
31 /*! \libinternal \file
33 * Declares gmx::test::StringTestBase.
35 * \author Teemu Murtola <teemu.murtola@cbr.su.se>
37 * \ingroup module_testutils
39 #ifndef GMX_TESTUTILS_STRINGTEST_H
40 #define GMX_TESTUTILS_STRINGTEST_H
44 #include <boost/scoped_ptr.hpp>
45 #include <gtest/gtest.h>
54 /*! \libinternal \brief
55 * Test fixture for tests that check string formatting.
57 * For development, tests that use this fixture as their base can be run with a
58 * '-stdout' command-line option to print out the tested strings to stdout.
59 * If this flag is not given, they check the strings using the XML reference
60 * framework (see TestReferenceData).
63 * \ingroup module_testutils
65 class StringTestBase : public ::testing::Test
68 //! Static fixture setup to parse command-line options.
69 static void SetUpTestCase();
75 * Returns the root checker for this test's reference data.
77 * Can be used to perform custom checks against reference data (e.g.,
78 * if the test needs to check some other values than plain strings.
80 TestReferenceChecker &checker();
85 * \param[in] text String to check.
86 * \param[in] id Unique (within a single test) id for the string.
88 void checkText(const std::string &text, const char *id);
90 * Check contents of a file as a single string.
92 * \param[in] filename Name of the file to check.
93 * \param[in] id Unique (within a single test) id for the string.
95 * Provided for convenience. Reads the contents of \p filename into a
96 * single string and calls checkText().
98 void checkFileContents(const std::string &filename, const char *id);
101 static bool s_bWriteToStdOut;
103 TestReferenceData data_;
104 boost::scoped_ptr<TestReferenceChecker> checker_;