From c22db006f999cfd012d6b611926cb2bf126e7824 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Mon, 19 Jun 2017 15:23:03 +0200 Subject: [PATCH] Added method to verify report steps. --- opm/test_util/summaryComparator.cpp | 20 ++++++++++++++++++++ opm/test_util/summaryComparator.hpp | 3 +++ opm/test_util/summaryRegressionTest.cpp | 7 ++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/opm/test_util/summaryComparator.cpp b/opm/test_util/summaryComparator.cpp index 3b38003..df20e4d 100644 --- a/opm/test_util/summaryComparator.cpp +++ b/opm/test_util/summaryComparator.cpp @@ -83,6 +83,26 @@ void SummaryComparator::setTimeVecs(std::vector &timeVec1, } +bool SummaryComparator::checkReportSteps() const { + int first = ecl_sum_get_first_report_step( ecl_sum1 ); + int last = ecl_sum_get_last_report_step( ecl_sum1 ); + + if (ecl_sum_get_first_report_step(ecl_sum2) != first) + return false; + + if (ecl_sum_get_last_report_step(ecl_sum2) != last) + return false; + + for (int step=first; step <= last; ++step) { + if (ecl_sum_get_report_time( ecl_sum1 , step ) != ecl_sum_get_report_time( ecl_sum2 , step)) + return false; + } + + return true; +} + + + void SummaryComparator::getDataVecs(std::vector &dataVec1, std::vector &dataVec2, const char* keyword){ diff --git a/opm/test_util/summaryComparator.hpp b/opm/test_util/summaryComparator.hpp index 4fe9018..6453792 100644 --- a/opm/test_util/summaryComparator.hpp +++ b/opm/test_util/summaryComparator.hpp @@ -175,6 +175,9 @@ class SummaryComparator { //! \brief Set whether to throw on errors or not. void throwOnErrors(bool dothrow) { throwOnError = dothrow; } + + //! \brief Will check if the two summary cases have identical report times + bool checkReportSteps() const; }; #endif diff --git a/opm/test_util/summaryRegressionTest.cpp b/opm/test_util/summaryRegressionTest.cpp index 5675ad6..c67472c 100644 --- a/opm/test_util/summaryRegressionTest.cpp +++ b/opm/test_util/summaryRegressionTest.cpp @@ -50,9 +50,14 @@ void RegressionTest::getRegressionTest(){ printKeywords(); } - //Iterates over all keywords from the restricted file, use iterator "ivar". Searches for a match in the file with more keywords, use the iterator "jvar". bool throwAtEnd = false; + + if (!checkReportSteps( )) { + HANDLE_ERROR(std::runtime_error, "Report steps are not identical"); + throwAtEnd = true; + } + while(ivar < stringlist_get_size(keysShort)){ const char* keyword = stringlist_iget(keysShort, ivar); std::string keywordString(keyword);