Browse Source

Compare floating points upto precision instead ==

Fixes QuantileQueryTest with CLN
Provided by Tim Quatmann
tempestpy_adaptions
Daniel Basgöze 3 years ago
committed by Stefan Pranger
parent
commit
1dab437496
  1. 5
      src/test/storm/modelchecker/prctl/mdp/QuantileQueryTest.cpp

5
src/test/storm/modelchecker/prctl/mdp/QuantileQueryTest.cpp

@ -98,6 +98,7 @@ namespace {
std::pair<bool, std::string> compareResult(std::shared_ptr<storm::models::sparse::Model<ValueType>> const& model, std::unique_ptr<storm::modelchecker::CheckResult>& result, std::vector<std::string> const& expected) { std::pair<bool, std::string> compareResult(std::shared_ptr<storm::models::sparse::Model<ValueType>> const& model, std::unique_ptr<storm::modelchecker::CheckResult>& result, std::vector<std::string> const& expected) {
bool equal = true; bool equal = true;
std::string errorMessage = ""; std::string errorMessage = "";
ValueType comparePrecision = std::is_same<ValueType, double>::value ? storm::utility::convertNumber<ValueType>(1e-10) : storm::utility::zero<ValueType>();
auto filter = getInitialStateFilter(model); auto filter = getInitialStateFilter(model);
result->filter(*filter); result->filter(*filter);
std::vector<std::vector<ValueType>> resultPoints; std::vector<std::vector<ValueType>> resultPoints;
@ -120,7 +121,7 @@ namespace {
for (auto const& resPoint : resultPoints) { for (auto const& resPoint : resultPoints) {
bool contained = false; bool contained = false;
for (auto const& expPoint : expectedPoints) { for (auto const& expPoint : expectedPoints) {
if (resPoint == expPoint) {
if (storm::utility::vector::equalModuloPrecision(resPoint, expPoint, comparePrecision, true)) {
contained = true; contained = true;
break; break;
} }
@ -133,7 +134,7 @@ namespace {
for (auto const& expPoint : expectedPoints) { for (auto const& expPoint : expectedPoints) {
bool contained = false; bool contained = false;
for (auto const& resPoint : resultPoints) { for (auto const& resPoint : resultPoints) {
if (resPoint == expPoint) {
if (storm::utility::vector::equalModuloPrecision(resPoint, expPoint, comparePrecision, true)) {
contained = true; contained = true;
break; break;
} }

Loading…
Cancel
Save