Merge pull request #2780 from joakim-hove/rst_fixup2

Rst fixup2
This commit is contained in:
Joakim Hove
2021-10-25 17:37:47 +02:00
committed by GitHub
3 changed files with 33 additions and 5 deletions

View File

@@ -66,7 +66,7 @@ struct Index {
bool operator==(const Index& other) const;
bool operator!=(const Index& other) const;
bool operator<(const Index& other) const;
Index operator+(std::size_t shift) const;
private:
const FileDeck * deck;

View File

@@ -92,6 +92,15 @@ FileDeck::Index FileDeck::Index::operator++(int) {
return current;
}
FileDeck::Index FileDeck::Index::operator+(std::size_t shift) const {
auto sum = *this;
for (std::size_t arg = 0; arg < shift; arg++)
sum++;
return sum;
}
bool FileDeck::Index::operator==(const Index& other) const {
return this->file_index == other.file_index &&
@@ -441,7 +450,7 @@ void FileDeck::skip(int report_step) {
throw std::logic_error(fmt::format("Could not find DATES keyword corresponding to report_step {}", report_step));
}
auto index = schedule.value();
auto index = schedule.value() + 1;
auto end_pos = deck_pos;
while (index < end_pos) {
const auto& keyword = this->operator[](index);
@@ -461,7 +470,7 @@ void FileDeck::skip(int report_step) {
using D = ParserKeywords::DATES;
current_report -= deck_keyword.size();
for (int record_index = 0; record_index < (report_step - current_report); record_index++) {
for (int record_index = report_step - current_report; record_index < deck_keyword.size(); record_index++) {
const auto& record = deck_keyword[record_index];
records.push_back( {DeckValue{record.getItem<D::DAY>().get<int>(0)},
DeckValue{record.getItem<D::MONTH>().get<std::string>(0)},

View File

@@ -278,6 +278,12 @@ BOOST_AUTO_TEST_CASE(TestFileDeck)
const auto& dimens2 = fd.find("DIMENS", ++offset);
BOOST_CHECK(!dimens2.has_value());
auto index2p1 = index2.value() + 1;
BOOST_CHECK(index2.value() < index2p1);
const auto& kw = fd[index2p1];
BOOST_CHECK_EQUAL(kw.name(), "START");
const auto& index3 = fd.find("COORD");
BOOST_CHECK_EQUAL( index3.value().file_index , 1);
BOOST_CHECK_EQUAL( index3.value().keyword_index, 3);
@@ -328,13 +334,26 @@ BOOST_AUTO_TEST_CASE(RestartTest23)
fd.skip(7);
BOOST_CHECK_EQUAL(fd.count("DATES"), 1);
BOOST_CHECK(fd.find("SCHEDULE").has_value());
auto dates_index = fd.find("DATES");
BOOST_CHECK(dates_index.has_value());
auto kw = fd[dates_index.value()];
auto rec0 = kw[0];
BOOST_CHECK_EQUAL( rec0.getItem<ParserKeywords::DATES::MONTH>().get<std::string>(0), "MAR");
BOOST_CHECK_EQUAL(kw.size() , 1);
BOOST_CHECK_EQUAL( rec0.getItem<ParserKeywords::DATES::MONTH>().get<std::string>(0), "APR");
BOOST_CHECK_EQUAL( kw.size() , 5);
}
BOOST_AUTO_TEST_CASE(RestartTest24)
{
Parser parser;
auto python = std::make_shared<Python>();
auto deck = parser.parseFile("UDQ_WCONPROD.DATA");
FileDeck fd(deck);
fd.skip(4);
BOOST_CHECK_EQUAL(fd.count("DATES"), 3);
BOOST_CHECK(fd.find("SCHEDULE").has_value());
}
BOOST_AUTO_TEST_CASE(RestartTest)