From 781ced7294f6cef6629010963dc89c5d42155076 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 17 Oct 2019 16:18:56 +0200 Subject: [PATCH] Use struct Location to record file position for keywords --- CMakeLists_files.cmake | 1 + examples/opmhash.cpp | 3 +- opm/common/OpmLog/Location.hpp | 35 +++++++++++++++++++ opm/common/OpmLog/LogUtil.hpp | 7 ++-- opm/parser/eclipse/Deck/DeckKeyword.hpp | 15 +------- .../Schedule/Action/Condition.hpp | 4 +-- .../EclipseState/Tables/TableManager.hpp | 3 +- src/opm/common/OpmLog/LogUtil.cpp | 12 +++---- src/opm/parser/eclipse/Deck/DeckKeyword.cpp | 10 +----- .../eclipse/EclipseState/EclipseState.cpp | 2 +- .../EclipseState/IOConfig/RestartConfig.cpp | 7 ++-- .../Schedule/Action/Condition.cpp | 2 +- .../EclipseState/Schedule/Schedule.cpp | 3 +- .../EclipseState/Schedule/VFPProdTable.cpp | 9 ++--- .../EclipseState/Tables/TableManager.cpp | 2 +- .../parser/eclipse/EclipseState/checkDeck.cpp | 6 ++-- src/opm/parser/eclipse/Parser/Parser.cpp | 25 ++++++------- tests/parser/ACTIONX.cpp | 3 +- tests/test_OpmLog.cpp | 7 ++-- 19 files changed, 92 insertions(+), 64 deletions(-) create mode 100644 opm/common/OpmLog/Location.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index 04c272e04..5b19ff81c 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -429,6 +429,7 @@ list( APPEND PUBLIC_HEADER_FILES opm/common/OpmLog/LogUtil.hpp opm/common/OpmLog/MessageFormatter.hpp opm/common/OpmLog/MessageLimiter.hpp + opm/common/OpmLog/Location.hpp opm/common/OpmLog/OpmLog.hpp opm/common/OpmLog/StreamLog.hpp opm/common/OpmLog/TimerLog.hpp diff --git a/examples/opmhash.cpp b/examples/opmhash.cpp index 016ea0716..39e44c911 100644 --- a/examples/opmhash.cpp +++ b/examples/opmhash.cpp @@ -64,9 +64,10 @@ std::vector load_deck(const char * deck_file) { auto deck = parser.parseFile(deck_file, parseContext, errors); for (const auto& kw : deck) { std::stringstream ss; + const auto& location = kw.location(); ss << kw; - keywords.emplace_back(kw.name(), kw.getFileName(), kw.getLineNumber(), std::hash{}(ss.str())); + keywords.emplace_back(kw.name(), location.filename, location.lineno, std::hash{}(ss.str())); } return keywords; } diff --git a/opm/common/OpmLog/Location.hpp b/opm/common/OpmLog/Location.hpp new file mode 100644 index 000000000..166d3d434 --- /dev/null +++ b/opm/common/OpmLog/Location.hpp @@ -0,0 +1,35 @@ +/* + Copyright 2015 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef LOCATION_HPP +#define LOCATION_HPP + +class Location { +public: + std::string filename = ""; + std::size_t lineno = 0; + + Location() = default; + Location(std::string fname, std::size_t lno) : + filename(std::move(fname)), + lineno(lno) + {} +}; + +#endif diff --git a/opm/common/OpmLog/LogUtil.hpp b/opm/common/OpmLog/LogUtil.hpp index 9769681a4..285e1ce17 100644 --- a/opm/common/OpmLog/LogUtil.hpp +++ b/opm/common/OpmLog/LogUtil.hpp @@ -23,7 +23,10 @@ #include #include +#include + namespace Opm { + namespace Log { namespace MessageType { const int64_t Debug = 1; /* Excessive information */ @@ -56,8 +59,8 @@ namespace Log { bool isPower2(int64_t x); - std::string fileMessage(const std::string& path, int line , const std::string& msg); - std::string fileMessage(int64_t messageType , const std::string& path, int line , const std::string& msg); + std::string fileMessage(const Location& location, const std::string& msg); + std::string fileMessage(int64_t messageType , const Location& location , const std::string& msg); std::string prefixMessage(int64_t messageType , const std::string& msg); std::string colorCodeMessage(int64_t messageType , const std::string& msg); diff --git a/opm/parser/eclipse/Deck/DeckKeyword.hpp b/opm/parser/eclipse/Deck/DeckKeyword.hpp index 6059211e3..f811aaeb4 100644 --- a/opm/parser/eclipse/Deck/DeckKeyword.hpp +++ b/opm/parser/eclipse/Deck/DeckKeyword.hpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace Opm { class DeckOutput; @@ -36,18 +37,6 @@ namespace Opm { class DeckKeyword { public: - class Location { - public: - std::string filename; - std::size_t lineno; - - Location() = default; - Location(std::string fname, std::size_t lno) : - filename(std::move(fname)), - lineno(lno) - {} - }; - typedef std::vector< DeckRecord >::const_iterator const_iterator; @@ -63,8 +52,6 @@ namespace Opm { const std::string& name() const; void setFixedSize(); void setLocation(const std::pair& location); - const std::string& getFileName() const; - int getLineNumber() const; const Location& location() const; diff --git a/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp b/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp index dcdac0a20..a4b730d67 100644 --- a/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp +++ b/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.hpp @@ -23,7 +23,7 @@ #include #include -#include +#include namespace Opm { @@ -64,7 +64,7 @@ enum class Comparator { }; - Condition(const std::vector& tokens, const DeckKeyword::Location& location); + Condition(const std::vector& tokens, const Location& location); Quantity lhs; diff --git a/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp b/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp index 888aee9b3..a462180c1 100644 --- a/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp +++ b/opm/parser/eclipse/EclipseState/Tables/TableManager.hpp @@ -299,7 +299,8 @@ namespace Opm { // should be copied... if (tableIdx == 0) { std::string msg = "The first table for keyword "+keywordName+" must be explicitly defined! Ignoring keyword"; - OpmLog::warning(Log::fileMessage(tableKeyword.getFileName(), tableKeyword.getLineNumber(), msg)); + const auto& location = tableKeyword.location(); + OpmLog::warning(Log::fileMessage(location, msg)); return; } tableVector.push_back(tableVector.back()); diff --git a/src/opm/common/OpmLog/LogUtil.cpp b/src/opm/common/OpmLog/LogUtil.cpp index bc94ce364..0fd01f7dc 100644 --- a/src/opm/common/OpmLog/LogUtil.cpp +++ b/src/opm/common/OpmLog/LogUtil.cpp @@ -32,16 +32,16 @@ namespace Log { - std::string fileMessage(const std::string& filename , int line , const std::string& message) { + std::string fileMessage(const Location& location, const std::string& message) { std::ostringstream oss; - oss << message << "\n" << "In file " << filename << ", line " << line << "\n"; + oss << message << "\n" << "In file " << location.filename << ", line " << location.lineno << "\n"; return oss.str(); } - std::string fileMessage(int64_t messageType , const std::string& filename , int line , const std::string& message) { - return fileMessage( filename , line , prefixMessage( messageType , message )); + std::string fileMessage(int64_t messageType , const Location& location, const std::string& message) { + return fileMessage( location , prefixMessage( messageType , message )); } @@ -86,8 +86,8 @@ namespace Log { case MessageType::Warning: return AnsiTerminalColors::blue_strong + message + AnsiTerminalColors::none; case MessageType::Problem: - return AnsiTerminalColors::magenta_strong + message + AnsiTerminalColors::none; - case MessageType::Error: + return AnsiTerminalColors::magenta_strong + message + AnsiTerminalColors::none; + case MessageType::Error: case MessageType::Bug: return AnsiTerminalColors::red_strong + message + AnsiTerminalColors::none; default: diff --git a/src/opm/parser/eclipse/Deck/DeckKeyword.cpp b/src/opm/parser/eclipse/Deck/DeckKeyword.cpp index 60509a4b9..151aa565c 100644 --- a/src/opm/parser/eclipse/Deck/DeckKeyword.cpp +++ b/src/opm/parser/eclipse/Deck/DeckKeyword.cpp @@ -191,15 +191,7 @@ namespace Opm { this->m_location = Location(location.first, location.second); } - const std::string& DeckKeyword::getFileName() const { - return this->m_location.filename; - } - - int DeckKeyword::getLineNumber() const { - return this->m_location.lineno; - } - - const DeckKeyword::Location& DeckKeyword::location() const { + const Location& DeckKeyword::location() const { return this->m_location; } diff --git a/src/opm/parser/eclipse/EclipseState/EclipseState.cpp b/src/opm/parser/eclipse/EclipseState/EclipseState.cpp index f6ae29e77..18a859b41 100644 --- a/src/opm/parser/eclipse/EclipseState/EclipseState.cpp +++ b/src/opm/parser/eclipse/EclipseState/EclipseState.cpp @@ -232,7 +232,7 @@ namespace Opm { auto keywords = deck.getKeywordList(keywordName); for (size_t i = 0; i < keywords.size(); ++i) { std::string msg = "Ambiguous keyword "+keywordName+" defined here"; - OpmLog::error(Log::fileMessage(keywords[i]->getFileName(), keywords[i]->getLineNumber(), msg)); + OpmLog::error(Log::fileMessage(keywords[i]->location(), msg)); } } diff --git a/src/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp b/src/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp index e86f176ff..5f109ad75 100644 --- a/src/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp +++ b/src/opm/parser/eclipse/EclipseState/IOConfig/RestartConfig.cpp @@ -322,7 +322,8 @@ inline std::map< std::string, int > RPT( const DeckKeyword& keyword, if (ints && strs) { - std::string msg = "Mixed style input is not allowed for keyword: " + keyword.name() + " at " + keyword.getFileName() + "(" + std::to_string( keyword.getLineNumber() ) + ")"; + const auto& location = keyword.location(); + std::string msg = "Mixed style input is not allowed for keyword: " + keyword.name() + " at " + location.filename + "(" + std::to_string( location.lineno ) + ")"; parseContext.handleError(ParseContext::RPT_MIXED_STYLE, msg, errors); std::vector stack; @@ -330,7 +331,7 @@ inline std::map< std::string, int > RPT( const DeckKeyword& keyword, if (is_int(deck_items[index])) { if (stack.size() < 2) { - std::string errmsg = "Can not interpret " + keyword.name() + " at " + keyword.getFileName() + "(" + std::to_string( keyword.getLineNumber() ) + ")"; + std::string errmsg = "Can not interpret " + keyword.name() + " at " + location.filename + "(" + std::to_string( location.lineno ) + ")"; throw std::invalid_argument(errmsg); } @@ -343,7 +344,7 @@ inline std::map< std::string, int > RPT( const DeckKeyword& keyword, stack.clear(); items.push_back( mnemonic + "=" + deck_items[index]); } else { - std::string errmsg = "Can not interpret " + keyword.name() + " at " + keyword.getFileName() + "(" + std::to_string( keyword.getLineNumber() ) + ")"; + std::string errmsg = "Can not interpret " + keyword.name() + " at " + location.filename + "(" + std::to_string( location.lineno ) + ")"; throw std::invalid_argument(errmsg); } diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp index 31312f30a..877dc57fc 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Action/Condition.cpp @@ -84,7 +84,7 @@ void Quantity::add_arg(const std::string& arg) { this->args.push_back(strip_quotes(arg)); } -Condition::Condition(const std::vector& tokens, const DeckKeyword::Location& location) { +Condition::Condition(const std::vector& tokens, const Location& location) { this->lhs = Quantity(tokens[0]); std::size_t token_index = 1; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp index ac8c42ff8..1152d9405 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/Schedule.cpp @@ -95,7 +95,8 @@ namespace { std::string trim_wgname(const DeckKeyword& keyword, const std::string& wgname_arg, const ParseContext& parseContext, ErrorGuard errors) { std::string wgname = boost::algorithm::trim_copy(wgname_arg); if (wgname != wgname_arg) { - std::string msg = "Illegal space: \"" + wgname_arg + "\" found when defining WELL/GROUP in keyword: " + keyword.name() + " at " + keyword.getFileName() + ":" + std::to_string(keyword.getLineNumber()); + const auto& location = keyword.location(); + std::string msg = "Illegal space: \"" + wgname_arg + "\" found when defining WELL/GROUP in keyword: " + keyword.name() + " at " + location.filename + ":" + std::to_string(location.lineno); parseContext.handleError(ParseContext::PARSE_WGNAME_SPACE, msg, errors); } return wgname; diff --git a/src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp b/src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp index b9b2d3225..982ab8afc 100644 --- a/src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp +++ b/src/opm/parser/eclipse/EclipseState/Schedule/VFPProdTable.cpp @@ -399,13 +399,14 @@ void VFPProdTable::check(const DeckKeyword& keyword, const double table_scaling_ } if (!points.empty()) { - OpmLog::warning("VFP table for production wells has BHP versus THP not " + const auto& location = keyword.location(); + OpmLog::warning("VFP table for production wells has BHP versus THP not " + std::string("monotonically increasing.\nThis may cause convergence ") + "issues due to switching between BHP and THP control mode." - + std::string("\nIn keyword VFPPROD table number ") + + std::string("\nIn keyword VFPPROD table number ") + std::to_string(m_table_num) - + ", file " + keyword.getFileName() - + ", line " + std::to_string(keyword.getLineNumber()) + + ", file " + location.filename + + ", line " + std::to_string(location.lineno) + "\n"); OpmLog::note(points); } diff --git a/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp b/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp index de70ffc83..39c0b5a20 100644 --- a/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp +++ b/src/opm/parser/eclipse/EclipseState/Tables/TableManager.cpp @@ -895,7 +895,7 @@ namespace Opm { const auto& keywords = deck.getKeywordList(keywordName); for (size_t i = 0; i < keywords.size(); ++i) { std::string msg = "Ambiguous keyword "+keywordName+" defined here"; - OpmLog::error(Log::fileMessage(keywords[i]->getFileName(), keywords[i]->getLineNumber(), msg)); + OpmLog::error(Log::fileMessage(keywords[i]->location(), msg)); } } diff --git a/src/opm/parser/eclipse/EclipseState/checkDeck.cpp b/src/opm/parser/eclipse/EclipseState/checkDeck.cpp index 98424776f..38f534e8b 100644 --- a/src/opm/parser/eclipse/EclipseState/checkDeck.cpp +++ b/src/opm/parser/eclipse/EclipseState/checkDeck.cpp @@ -38,7 +38,8 @@ bool checkDeck( const Deck& deck, const Parser& parser, const ParseContext& pars const auto& keyword = deck.getKeyword(keywordIdx); if (!parser.isRecognizedKeyword( keyword.name() ) ) { std::string msg("Keyword '" + keyword.name() + "' is unknown."); - OpmLog::warning( Log::fileMessage(keyword.getFileName(), keyword.getLineNumber(), msg) ); + const auto& location = keyword.location(); + OpmLog::warning( Log::fileMessage(location, msg) ); deckValid = false; } } @@ -55,9 +56,10 @@ bool checkDeck( const Deck& deck, const Parser& parser, const ParseContext& pars const std::string& fileUnitSystem = boost::to_upper_copy(keyword->getRecord(0).getItem("FILE_UNIT_SYSTEM").getTrimmedString(0)); if (fileUnitSystem != deckUnitSystem) { + const auto& location = keyword->location(); std::string msg = "Unit system " + fileUnitSystem + " specified via the FILEUNIT keyword at " - + keyword->getFileName() + ":" + std::to_string(keyword->getLineNumber()) + + location.filename + ":" + std::to_string(location.lineno) + " does not correspond to the unit system used by the deck (" + deckUnitSystem + ")"; parseContext.handleError(ParseContext::UNIT_SYSTEM_MISMATCH, msg, errorGuard); diff --git a/src/opm/parser/eclipse/Parser/Parser.cpp b/src/opm/parser/eclipse/Parser/Parser.cpp index b558fe3b7..65cc42eda 100644 --- a/src/opm/parser/eclipse/Parser/Parser.cpp +++ b/src/opm/parser/eclipse/Parser/Parser.cpp @@ -857,7 +857,8 @@ bool parseState( ParserState& parserState, const Parser& parser ) { } } else { const std::string msg = "The keyword " + rawKeyword->getKeywordName() + " is not recognized - ignored"; - OpmLog::warning(Log::fileMessage(parserState.current_path().string(), parserState.line(), msg)); + Location location(parserState.current_path().string(), parserState.line()); + OpmLog::warning(Log::fileMessage(location, msg)); } } @@ -1159,7 +1160,7 @@ std::vector Parser::getAllDeckNames () const { if( deck.getKeyword(0).name() != "RUNSPEC" ) { std::string msg = "The first keyword of a valid deck must be RUNSPEC\n"; auto curKeyword = deck.getKeyword(0); - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } @@ -1179,7 +1180,7 @@ std::vector Parser::getAllDeckNames () const { std::string msg = "The keyword '"+curKeywordName+"' is located in the '"+curSectionName +"' section where it is invalid"; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } @@ -1190,7 +1191,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "GRID") { std::string msg = "The RUNSPEC section must be followed by GRID instead of "+curKeywordName; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } @@ -1200,7 +1201,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "EDIT" && curKeywordName != "PROPS") { std::string msg = "The GRID section must be followed by EDIT or PROPS instead of "+curKeywordName; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } @@ -1210,7 +1211,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "PROPS") { std::string msg = "The EDIT section must be followed by PROPS instead of "+curKeywordName; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } @@ -1220,7 +1221,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "REGIONS" && curKeywordName != "SOLUTION") { std::string msg = "The PROPS section must be followed by REGIONS or SOLUTION instead of "+curKeywordName; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } @@ -1230,7 +1231,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "SOLUTION") { std::string msg = "The REGIONS section must be followed by SOLUTION instead of "+curKeywordName; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } @@ -1240,7 +1241,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "SUMMARY" && curKeywordName != "SCHEDULE") { std::string msg = "The SOLUTION section must be followed by SUMMARY or SCHEDULE instead of "+curKeywordName; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } @@ -1250,7 +1251,7 @@ std::vector Parser::getAllDeckNames () const { if (curKeywordName != "SCHEDULE") { std::string msg = "The SUMMARY section must be followed by SCHEDULE instead of "+curKeywordName; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } @@ -1261,7 +1262,7 @@ std::vector Parser::getAllDeckNames () const { std::string msg = "The SCHEDULE section must be the last one (" +curKeywordName+" specified after SCHEDULE)"; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } } @@ -1271,7 +1272,7 @@ std::vector Parser::getAllDeckNames () const { const auto& curKeyword = deck.getKeyword(deck.size() - 1); std::string msg = "The last section of a valid deck must be SCHEDULE (is "+curSectionName+")"; - OpmLog::warning(Log::fileMessage(curKeyword.getFileName(), curKeyword.getLineNumber(), msg) ); + OpmLog::warning(Log::fileMessage(curKeyword.location(), msg) ); deckValid = false; } diff --git a/tests/parser/ACTIONX.cpp b/tests/parser/ACTIONX.cpp index c5512d8b4..587814588 100644 --- a/tests/parser/ACTIONX.cpp +++ b/tests/parser/ACTIONX.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -597,7 +598,7 @@ BOOST_AUTO_TEST_CASE(TestFieldAND) { BOOST_AUTO_TEST_CASE(Conditions) { - auto location = DeckKeyword::Location("File", 100); + auto location = Location("File", 100); // Missing comparator BOOST_CHECK_THROW(Action::Condition cond({"WWCT", "OPX"}, location), std::invalid_argument); diff --git a/tests/test_OpmLog.cpp b/tests/test_OpmLog.cpp index 68d358c3e..d28676331 100644 --- a/tests/test_OpmLog.cpp +++ b/tests/test_OpmLog.cpp @@ -36,6 +36,7 @@ #include #include #include +#include using namespace Opm; @@ -47,7 +48,7 @@ BOOST_AUTO_TEST_CASE(DoLogging) { BOOST_AUTO_TEST_CASE(Test_Format) { - BOOST_CHECK_EQUAL( "There is an error here?\nIn file /path/to/file, line 100\n" , Log::fileMessage("/path/to/file" , 100 , "There is an error here?")); + BOOST_CHECK_EQUAL( "There is an error here?\nIn file /path/to/file, line 100\n" , Log::fileMessage(Location("/path/to/file" , 100) , "There is an error here?")); BOOST_CHECK_EQUAL( "\nError: This is the error" , Log::prefixMessage(Log::MessageType::Error , "This is the error")); BOOST_CHECK_EQUAL( "\nWarning: This is the warning" , Log::prefixMessage(Log::MessageType::Warning , "This is the warning")); @@ -251,8 +252,8 @@ BOOST_AUTO_TEST_CASE(TestHelperFunctions) BOOST_CHECK(isPower2(1ul << 62)); // fileMessage - BOOST_CHECK_EQUAL(fileMessage("foo/bar", 1, "message"), "message\nIn file foo/bar, line 1\n"); - BOOST_CHECK_EQUAL(fileMessage(MessageType::Error, "foo/bar", 1, "message"), "\nError: message\nIn file foo/bar, line 1\n"); + BOOST_CHECK_EQUAL(fileMessage(Location("foo/bar", 1), "message"), "message\nIn file foo/bar, line 1\n"); + BOOST_CHECK_EQUAL(fileMessage(MessageType::Error, Location("foo/bar", 1), "message"), "\nError: message\nIn file foo/bar, line 1\n"); // prefixMessage BOOST_CHECK_EQUAL(prefixMessage(MessageType::Error, "message"), "\nError: message");