namespace
{
+// Define the set of PBCs to run the test for
+const std::vector<t_pbc> c_pbcs = [] {
+ std::vector<t_pbc> pbcs;
+ t_pbc pbc;
+
+ // Infinitely small box
+ matrix boxNone = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
+ set_pbc(&pbc, PbcType::No, boxNone);
+ pbcs.emplace_back(pbc);
+
+ // Rectangular box
+ matrix boxXyz = { { 10.0, 0.0, 0.0 }, { 0.0, 20.0, 0.0 }, { 0.0, 0.0, 15.0 } };
+ set_pbc(&pbc, PbcType::Xyz, boxXyz);
+ pbcs.emplace_back(pbc);
+
+ return pbcs;
+}();
+
/*! \brief Test fixture for constraints.
*
* The fixture uses following test systems:
* For some systems, the value for scaled virial tensor is checked against
* pre-computed data.
*/
-class ConstraintsTest : public ::testing::TestWithParam<std::string>
+class ConstraintsTest : public ::testing::TestWithParam<t_pbc>
{
public:
- //! PBC setups
- std::unordered_map<std::string, t_pbc> pbcs_;
-
- /*! \brief Test setup function.
- *
- * Setting up the pbcs and algorithms. Note, that corresponding string keywords
- * have to be explicitly added at the end of this file when the tests are called.
- *
- */
- void SetUp() override
- {
-
- //
- // PBC initialization
- //
- t_pbc pbc;
-
- // Infinitely small box
- matrix boxNone = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
- set_pbc(&pbc, PbcType::No, boxNone);
- pbcs_["PBCNone"] = pbc;
-
- // Rectangular box
- matrix boxXyz = { { 10.0, 0.0, 0.0 }, { 0.0, 20.0, 0.0 }, { 0.0, 0.0, 15.0 } };
- set_pbc(&pbc, PbcType::Xyz, boxXyz);
- pbcs_["PBCXYZ"] = pbc;
- }
-
/*! \brief
* The test on the final length of constrained bonds.
*
real(0.0), real(0.001), x, xPrime, v, shakeTolerance, shakeUseSOR, lincsNIter,
lincslincsExpansionOrder, lincsWarnAngle);
- std::string pbcName = GetParam();
- t_pbc pbc = pbcs_.at(pbcName);
+ t_pbc pbc = GetParam();
// Cycle through all available runners
for (const auto& runner : getRunners())
{
- SCOPED_TRACE(formatString("Testing %s with %s using %s.", testData->title_.c_str(),
- pbcName.c_str(), runner->name().c_str()));
+ SCOPED_TRACE(formatString("Testing %s with %s PBC using %s.", testData->title_.c_str(),
+ c_pbcTypeNames[pbc.pbcType].c_str(), runner->name().c_str()));
testData->reset();
real(0.0), real(0.001), x, xPrime, v, shakeTolerance, shakeUseSOR, lincsNIter,
lincslincsExpansionOrder, lincsWarnAngle);
- std::string pbcName = GetParam();
- t_pbc pbc = pbcs_.at(pbcName);
+ t_pbc pbc = GetParam();
// Cycle through all available runners
for (const auto& runner : getRunners())
{
- SCOPED_TRACE(formatString("Testing %s with %s using %s.", testData->title_.c_str(),
- pbcName.c_str(), runner->name().c_str()));
+ SCOPED_TRACE(formatString("Testing %s with %s PBC using %s.", testData->title_.c_str(),
+ c_pbcTypeNames[pbc.pbcType].c_str(), runner->name().c_str()));
testData->reset();
real(0.0), real(0.001), x, xPrime, v, shakeTolerance, shakeUseSOR, lincsNIter,
lincslincsExpansionOrder, lincsWarnAngle);
- std::string pbcName = GetParam();
- t_pbc pbc = pbcs_.at(pbcName);
+ t_pbc pbc = GetParam();
// Cycle through all available runners
for (const auto& runner : getRunners())
{
- SCOPED_TRACE(formatString("Testing %s with %s using %s.", testData->title_.c_str(),
- pbcName.c_str(), runner->name().c_str()));
+ SCOPED_TRACE(formatString("Testing %s with %s PBC using %s.", testData->title_.c_str(),
+ c_pbcTypeNames[pbc.pbcType].c_str(), runner->name().c_str()));
testData->reset();
real(0.0), real(0.001), x, xPrime, v, shakeTolerance, shakeUseSOR, lincsNIter,
lincslincsExpansionOrder, lincsWarnAngle);
- std::string pbcName = GetParam();
- t_pbc pbc = pbcs_.at(pbcName);
+ t_pbc pbc = GetParam();
// Cycle through all available runners
for (const auto& runner : getRunners())
{
- SCOPED_TRACE(formatString("Testing %s with %s using %s.", testData->title_.c_str(),
- pbcName.c_str(), runner->name().c_str()));
+ SCOPED_TRACE(formatString("Testing %s with %s PBC using %s.", testData->title_.c_str(),
+ c_pbcTypeNames[pbc.pbcType].c_str(), runner->name().c_str()));
testData->reset();
real(0.0), real(0.001), x, xPrime, v, shakeTolerance, shakeUseSOR, lincsNIter,
lincslincsExpansionOrder, lincsWarnAngle);
- std::string pbcName = GetParam();
- t_pbc pbc = pbcs_.at(pbcName);
+ t_pbc pbc = GetParam();
// Cycle through all available runners
for (const auto& runner : getRunners())
{
- SCOPED_TRACE(formatString("Testing %s with %s using %s.", testData->title_.c_str(),
- pbcName.c_str(), runner->name().c_str()));
+ SCOPED_TRACE(formatString("Testing %s with %s PBC using %s.", testData->title_.c_str(),
+ c_pbcTypeNames[pbc.pbcType].c_str(), runner->name().c_str()));
testData->reset();
real(0.0), real(0.001), x, xPrime, v, shakeTolerance, shakeUseSOR, lincsNIter,
lincslincsExpansionOrder, lincsWarnAngle);
- std::string pbcName = GetParam();
- t_pbc pbc = pbcs_.at(pbcName);
+ t_pbc pbc = GetParam();
// Cycle through all available runners
for (const auto& runner : getRunners())
{
- SCOPED_TRACE(formatString("Testing %s with %s using %s.", testData->title_.c_str(),
- pbcName.c_str(), runner->name().c_str()));
+ SCOPED_TRACE(formatString("Testing %s with %s PBC using %s.", testData->title_.c_str(),
+ c_pbcTypeNames[pbc.pbcType].c_str(), runner->name().c_str()));
testData->reset();
}
}
-
-INSTANTIATE_TEST_CASE_P(WithParameters, ConstraintsTest, ::testing::Values("PBCNone", "PBCXYZ"));
+INSTANTIATE_TEST_CASE_P(WithParameters, ConstraintsTest, ::testing::ValuesIn(c_pbcs));
} // namespace
} // namespace test