Skip to content

Commit

Permalink
Show more info about failing consistency tests
Browse files Browse the repository at this point in the history
  • Loading branch information
speth authored and ischoegl committed Jun 10, 2022
1 parent e13a19a commit 2472923
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/thermo/consistency.cpp
Expand Up @@ -19,6 +19,18 @@ AnyMap getSetup(const string& name) {
return cases[name]["input"].as<AnyMap>();
}

// For more informative output about failing test cases
std::ostream& operator<<(std::ostream& s, const AnyMap& m)
{
if (m.hasKey("file")) {
s << fmt::format("file: {}, phase: {}",
m["file"].asString(), m.getString("phase", "<default>"));
} else {
s << "\n" << m.toYamlString();
}
return s;
}

class TestConsistency : public testing::TestWithParam<std::tuple<AnyMap, AnyMap>>
{
public:
Expand Down Expand Up @@ -70,7 +82,7 @@ TEST_P(TestConsistency, hk_eq_uk_plus_P_times_vk)
phase->getPartialMolarIntEnergies(uk.data());
phase->getPartialMolarVolumes(vk.data());
for (size_t k = 0; k < nsp; k++) {
EXPECT_NEAR(hk[k], uk[k] + p * vk[k], atol);
EXPECT_NEAR(hk[k], uk[k] + p * vk[k], atol) << "k = " << k;
}
}

Expand All @@ -81,7 +93,7 @@ TEST_P(TestConsistency, gk_eq_hk_minus_T_times_sk)
phase->getPartialMolarEnthalpies(hk.data());
phase->getPartialMolarEntropies(sk.data());
for (size_t k = 0; k < nsp; k++) {
EXPECT_NEAR(gk[k], hk[k] - T * sk[k], atol);
EXPECT_NEAR(gk[k], hk[k] - T * sk[k], atol) << "k = " << k;
}
}

Expand Down

0 comments on commit 2472923

Please sign in to comment.