Make the output of the constraints tests readable
authorArtem Zhmurov <zhmurov@gmail.com>
Thu, 26 Aug 2021 15:42:19 +0000 (15:42 +0000)
committerAndrey Alekseenko <al42and@gmail.com>
Thu, 26 Aug 2021 15:42:19 +0000 (15:42 +0000)
In parametrized tests, the failed runs output parameters. In order
for them to be meaningfull for human, the parameter types should be
provided with function that converts them to strings. This adds
these functions for t_pbc and ConstraintsTestSystem types in
constraints tests.

src/gromacs/mdlib/tests/constr.cpp

index a0922b45009318350d2c66fae31e1b17e46657fc..fbca1b6d340b0ad1a2acbca0d7ef594375705cd1 100644 (file)
 #include "constrtestdata.h"
 #include "constrtestrunners.h"
 
+//! Helper function to convert t_pbc into string and make test failure messages readable
+static void PrintTo(const t_pbc& pbc, std::ostream* os)
+{
+    *os << "PBC: " << c_pbcTypeNames[pbc.pbcType];
+}
+
+
 namespace gmx
 {
+
 namespace test
 {
 namespace
@@ -91,7 +99,6 @@ const std::vector<t_pbc> c_pbcs = [] {
     return pbcs;
 }();
 
-
 struct ConstraintsTestSystem
 {
     //! Human-friendly name of the system.
@@ -147,6 +154,12 @@ struct ConstraintsTestSystem
     FloatingPointTolerance virialTolerance = absoluteTolerance(0.0001);
 };
 
+//! Helper function to convert ConstraintsTestSystem into string and make test failure messages readable
+void PrintTo(const ConstraintsTestSystem& constraintsTestSystem, std::ostream* os)
+{
+    *os << constraintsTestSystem.title << " - " << constraintsTestSystem.numAtoms << " atoms";
+}
+
 const std::vector<ConstraintsTestSystem> c_constraintsTestSystemList = [] {
     std::vector<ConstraintsTestSystem> constraintsTestSystemList;
     {