Fix tune_pme
[gromacs.git] / src / gromacs / trajectoryanalysis / tests / clustsize.cpp
blobeda82a763555df7128aacaeb815c320daddcc9ad
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2017,2018, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 /*! \internal \file
36 * \brief
37 * Tests for gmx clustsize
39 * \todo These will be superseded by tests of the new style analysis
40 * modules.
42 * \author David van der Spoel <david.vanderspoel@icm.uu.se>
43 * \ingroup module_trajectoryanalysis
46 #include "gmxpre.h"
48 #include <cstring>
50 #include <string>
52 #include "gromacs/gmxana/gmx_ana.h"
54 #include "testutils/cmdlinetest.h"
55 #include "testutils/refdata.h"
56 #include "testutils/testasserts.h"
57 #include "testutils/textblockmatchers.h"
58 #include "testutils/xvgtest.h"
60 namespace gmx
63 namespace test
66 namespace
69 class ClustsizeTest : public CommandLineTestBase
71 public:
72 ClustsizeTest()
74 double tolerance = 1e-4;
75 test::XvgMatch xvg;
76 test::XvgMatch &toler = xvg.tolerance(gmx::test::relativeToleranceAsFloatingPoint(1, tolerance));
78 setOutputFile("-mc", ".xvg", toler);
79 setOutputFile("-nc", ".xvg", toler);
80 setOutputFile("-ac", ".xvg", toler);
81 setOutputFile("-hc", ".xvg", toler);
82 setInputFile("-f", "clustsize.pdb");
85 void runTest(const CommandLine &args)
87 CommandLine &cmdline = commandLine();
88 cmdline.merge(args);
90 gmx::test::TestReferenceChecker rootChecker(this->rootChecker());
91 rootChecker.checkString(args.toString(), "CommandLine");
93 ASSERT_EQ(0, gmx_clustsize(cmdline.argc(), cmdline.argv()));
95 checkOutputFiles();
99 TEST_F(ClustsizeTest, NoMolDefaultCutoff)
101 const char *const command[] = { "clustsize" };
102 CommandLine args = CommandLine(command);
104 setInputFile("-n", "clustsize.ndx");
106 runTest(args);
109 TEST_F(ClustsizeTest, NoMolShortCutoff)
111 const char *const command[] = { "clustsize", "-cut", "0.3" };
112 CommandLine args = CommandLine(command);
114 setInputFile("-n", "clustsize.ndx");
116 runTest(args);
119 TEST_F(ClustsizeTest, MolDefaultCutoff)
121 const char *const command[] = { "clustsize", "-mol" };
122 CommandLine args = CommandLine(command);
124 setInputFile("-s", "clustsize.tpr");
126 runTest(args);
129 TEST_F(ClustsizeTest, MolShortCutoff)
131 const char *const command[] = { "clustsize", "-mol", "-cut", "0.3" };
132 CommandLine args = CommandLine(command);
134 setInputFile("-s", "clustsize.tpr");
136 runTest(args);
139 TEST_F(ClustsizeTest, MolCSize)
141 const char *const command[] = { "clustsize", "-mol", "-nlevels", "6" };
142 CommandLine args = CommandLine(command);
144 setOutputFile("-o", ".xpm", ExactTextMatch());
145 setOutputFile("-ow", ".xpm", ExactTextMatch());
147 setInputFile("-s", "clustsize.tpr");
149 runTest(args);
152 } // namespace
154 } // namespace test
156 } // namespace gmx