2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2015,2016,2019, 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.
37 * Tests utilities for testing xvg files
39 * \author David van der Spoel <david.vanderspoel@icm.uu.se>
40 * \ingroup module_testutils
44 #include "testutils/xvgtest.h"
48 #include <gtest/gtest.h>
49 #include <gtest/gtest-spi.h>
51 #include "gromacs/utility/arrayref.h"
52 #include "gromacs/utility/stringstream.h"
54 #include "testutils/refdata.h"
55 #include "testutils/testasserts.h"
60 using gmx::test::checkXvgFile;
61 using gmx::test::XvgMatchSettings;
63 //! Input testing data - an inline xvg file.
64 const char* const input[] = { "0 2905.86 -410.199", "0.2 6656.67 -430.437",
65 "0.4 5262.44 -409.399", "0.6 5994.69 -405.763",
66 "0.8 5941.37 -408.337", "1 5869.87 -411.124" };
68 TEST(XvgTests, CreateFile)
72 gmx::test::TestReferenceData data(gmx::test::erefdataUpdateAll);
73 gmx::test::TestReferenceChecker checker(data.rootChecker());
74 // Convert char array to a stream and add it to the checker
75 gmx::StringInputStream sis(input);
76 checkXvgFile(&sis, &checker, XvgMatchSettings());
80 gmx::test::TestReferenceData data(gmx::test::erefdataCompare);
81 gmx::test::TestReferenceChecker checker(data.rootChecker());
82 // Convert char array to a stream and add it to the checker
83 gmx::StringInputStream sis(input);
84 checkXvgFile(&sis, &checker, XvgMatchSettings());
88 TEST(XvgTests, CheckMissing)
92 gmx::test::TestReferenceData data(gmx::test::erefdataUpdateAll);
93 gmx::test::TestReferenceChecker checker(data.rootChecker());
94 // Convert char array to a stream and add it to the checker
95 gmx::StringInputStream sis(input);
96 checkXvgFile(&sis, &checker, XvgMatchSettings());
99 const char* const input[] = { "0 2905.86 -410.199", "0.2 6656.67 -430.437",
100 "0.4 5262.44 -409.399" };
101 // Now check with missing data
102 gmx::test::TestReferenceData data(gmx::test::erefdataCompare);
103 gmx::test::TestReferenceChecker checker(data.rootChecker());
104 gmx::StringInputStream sis(input);
105 EXPECT_NONFATAL_FAILURE(checkXvgFile(&sis, &checker, XvgMatchSettings()),
110 TEST(XvgTests, CheckExtra)
114 gmx::test::TestReferenceData data(gmx::test::erefdataUpdateAll);
115 gmx::test::TestReferenceChecker checker(data.rootChecker());
116 // Convert char array to a stream and add it to the checker
117 gmx::StringInputStream sis(input);
118 checkXvgFile(&sis, &checker, XvgMatchSettings());
121 const char* const input[] = { "0 2905.86 -410.199", "0.2 6656.67 -430.437",
122 "0.4 5262.44 -409.399", "0.6 5994.69 -405.763",
123 "0.8 5941.37 -408.337", "1 5869.87 -411.124",
124 "1.2 5889.87 -413.124" };
125 // Now check with missing data
126 gmx::test::TestReferenceData data(gmx::test::erefdataCompare);
127 gmx::test::TestReferenceChecker checker(data.rootChecker());
128 gmx::StringInputStream sis(input);
129 EXPECT_NONFATAL_FAILURE(checkXvgFile(&sis, &checker, XvgMatchSettings()), "Row6");
133 TEST(XvgTests, ReadIncorrect)
137 gmx::test::TestReferenceData data(gmx::test::erefdataUpdateAll);
138 gmx::test::TestReferenceChecker checker(data.rootChecker());
139 // Convert char array to a stream and add it to the checker
140 gmx::StringInputStream sis(input);
141 checkXvgFile(&sis, &checker, XvgMatchSettings());
144 const char* const input[] = { "0 2905.86 -410.199", "0.2 6656.67 -430.437",
145 "0.4 5262.44 -409.399", "0.6 5994.69 -405.763",
146 "0.8 5941.37 -408.337", "1 5869.87 -421.124" };
147 // Now check with incorrect data
148 gmx::test::TestReferenceData data(gmx::test::erefdataCompare);
149 gmx::test::TestReferenceChecker checker(data.rootChecker());
150 gmx::StringInputStream sis(input);
151 EXPECT_NONFATAL_FAILURE(checkXvgFile(&sis, &checker, XvgMatchSettings()), "-411");