2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2015, 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"
59 //! Input testing data - an inline xvg file.
60 const char * const input
[] = {
62 "0.2 6656.67 -430.437",
63 "0.4 5262.44 -409.399",
64 "0.6 5994.69 -405.763",
65 "0.8 5941.37 -408.337",
69 TEST(XvgTests
, CreateFile
)
73 gmx::test::TestReferenceData
data(gmx::test::erefdataUpdateAll
);
74 gmx::test::TestReferenceChecker
checker(data
.rootChecker());
75 // Convert char array to a stream and add it to the checker
76 gmx::StringInputStream
sis(input
);
77 gmx::test::checkXvgFile(&sis
, &checker
);
81 gmx::test::TestReferenceData
data(gmx::test::erefdataCompare
);
82 gmx::test::TestReferenceChecker
checker(data
.rootChecker());
83 // Convert char array to a stream and add it to the checker
84 gmx::StringInputStream
sis(input
);
85 gmx::test::checkXvgFile(&sis
, &checker
);
89 TEST(XvgTests
, CheckMissing
)
93 gmx::test::TestReferenceData
data(gmx::test::erefdataUpdateAll
);
94 gmx::test::TestReferenceChecker
checker(data
.rootChecker());
95 // Convert char array to a stream and add it to the checker
96 gmx::StringInputStream
sis(input
);
97 gmx::test::checkXvgFile(&sis
, &checker
);
100 const char * const input
[] = {
101 "0 2905.86 -410.199",
102 "0.2 6656.67 -430.437",
103 "0.4 5262.44 -409.399"
105 // Now check with missing data
106 gmx::test::TestReferenceData
data(gmx::test::erefdataCompare
);
107 gmx::test::TestReferenceChecker
checker(data
.rootChecker());
108 gmx::StringInputStream
sis(input
);
109 EXPECT_NONFATAL_FAILURE(gmx::test::checkXvgFile(&sis
, &checker
), "absent");
113 TEST(XvgTests
, CheckExtra
)
117 gmx::test::TestReferenceData
data(gmx::test::erefdataUpdateAll
);
118 gmx::test::TestReferenceChecker
checker(data
.rootChecker());
119 // Convert char array to a stream and add it to the checker
120 gmx::StringInputStream
sis(input
);
121 gmx::test::checkXvgFile(&sis
, &checker
);
124 const char * const input
[] = {
125 "0 2905.86 -410.199",
126 "0.2 6656.67 -430.437",
127 "0.4 5262.44 -409.399",
128 "0.6 5994.69 -405.763",
129 "0.8 5941.37 -408.337",
130 "1 5869.87 -411.124",
131 "1.2 5889.87 -413.124"
133 // Now check with missing data
134 gmx::test::TestReferenceData
data(gmx::test::erefdataCompare
);
135 gmx::test::TestReferenceChecker
checker(data
.rootChecker());
136 gmx::StringInputStream
sis(input
);
137 EXPECT_NONFATAL_FAILURE(gmx::test::checkXvgFile(&sis
, &checker
), "Row6");
141 TEST(XvgTests
, ReadIncorrect
)
145 gmx::test::TestReferenceData
data(gmx::test::erefdataUpdateAll
);
146 gmx::test::TestReferenceChecker
checker(data
.rootChecker());
147 // Convert char array to a stream and add it to the checker
148 gmx::StringInputStream
sis(input
);
149 gmx::test::checkXvgFile(&sis
, &checker
);
152 const char * const input
[] = {
153 "0 2905.86 -410.199",
154 "0.2 6656.67 -430.437",
155 "0.4 5262.44 -409.399",
156 "0.6 5994.69 -405.763",
157 "0.8 5941.37 -408.337",
160 // Now check with incorrect data
161 gmx::test::TestReferenceData
data(gmx::test::erefdataCompare
);
162 gmx::test::TestReferenceChecker
checker(data
.rootChecker());
163 gmx::StringInputStream
sis(input
);
164 EXPECT_NONFATAL_FAILURE(gmx::test::checkXvgFile(&sis
, &checker
), "-411");