Code beautification with uncrustify
[alexxy/gromacs.git] / src / testutils / stringtest.h
1 /*
2  *
3  *                This source code is part of
4  *
5  *                 G   R   O   M   A   C   S
6  *
7  *          GROningen MAchine for Chemical Simulations
8  *
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.
13
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.
18  *
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.
25  *
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.
28  *
29  * For more info, check our website at http://www.gromacs.org
30  */
31 /*! \libinternal \file
32  * \brief
33  * Declares gmx::test::StringTestBase.
34  *
35  * \author Teemu Murtola <teemu.murtola@cbr.su.se>
36  * \inlibraryapi
37  * \ingroup module_testutils
38  */
39 #ifndef GMX_TESTUTILS_STRINGTEST_H
40 #define GMX_TESTUTILS_STRINGTEST_H
41
42 #include <string>
43
44 #include <boost/scoped_ptr.hpp>
45 #include <gtest/gtest.h>
46
47 #include "refdata.h"
48
49 namespace gmx
50 {
51 namespace test
52 {
53
54 /*! \libinternal \brief
55  * Test fixture for tests that check string formatting.
56  *
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).
61  *
62  * \inlibraryapi
63  * \ingroup module_testutils
64  */
65 class StringTestBase : public ::testing::Test
66 {
67     public:
68         //! Static fixture setup to parse command-line options.
69         static void SetUpTestCase();
70
71         StringTestBase();
72         ~StringTestBase();
73
74         /*! \brief
75          * Returns the root checker for this test's reference data.
76          *
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.
79          */
80         TestReferenceChecker &checker();
81
82         /*! \brief
83          * Check a string.
84          *
85          * \param[in] text  String to check.
86          * \param[in] id    Unique (within a single test) id for the string.
87          */
88         void checkText(const std::string &text, const char *id);
89         /*! \brief
90          * Check contents of a file as a single string.
91          *
92          * \param[in] filename  Name of the file to check.
93          * \param[in] id        Unique (within a single test) id for the string.
94          *
95          * Provided for convenience.  Reads the contents of \p filename into a
96          * single string and calls checkText().
97          */
98         void checkFileContents(const std::string &filename, const char *id);
99
100     private:
101         static bool                             s_bWriteToStdOut;
102
103         TestReferenceData                       data_;
104         boost::scoped_ptr<TestReferenceChecker> checker_;
105 };
106
107 } // namespace test
108 } // namespace gmx
109
110 #endif