Added one-argument ParseContext constructor.
This commit is contained in:
@@ -79,7 +79,9 @@ namespace Opm {
|
||||
class ParseContext {
|
||||
public:
|
||||
ParseContext();
|
||||
explicit ParseContext(InputError::Action default_action);
|
||||
explicit ParseContext(const std::vector<std::pair<std::string , InputError::Action>>& initial);
|
||||
|
||||
Message::type handleError( const std::string& errorKey, MessageContainer& msgContainer, const std::string& msg ) const;
|
||||
bool hasKey(const std::string& key) const;
|
||||
ParseContext withKey(const std::string& key, InputError::Action action = InputError::WARN) const;
|
||||
|
||||
@@ -56,6 +56,17 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This constructor will initialize all actions to @default_action. The
|
||||
environment variables will be used.
|
||||
*/
|
||||
|
||||
ParseContext::ParseContext(InputError::Action default_action) {
|
||||
initDefault();
|
||||
update(default_action);
|
||||
initEnv();
|
||||
}
|
||||
|
||||
void ParseContext::initDefault() {
|
||||
addKey(PARSE_UNKNOWN_KEYWORD);
|
||||
addKey(PARSE_RANDOM_TEXT);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <boost/filesystem.hpp>
|
||||
#define BOOST_TEST_MODULE ParseContextTests
|
||||
@@ -406,3 +407,13 @@ BOOST_AUTO_TEST_CASE( test_too_much_data ) {
|
||||
parseContext.update(ParseContext::PARSE_EXTRA_DATA , InputError::IGNORE );
|
||||
auto deck = parser.parseString( deckString , parseContext );
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(test_1arg_constructor) {
|
||||
setenv("OPM_ERRORS_IGNORE", "PARSE_RANDOM_SLASH", 1);
|
||||
{
|
||||
ParseContext ctx(InputError::WARN);
|
||||
BOOST_CHECK_EQUAL(ctx.get(ParseContext::UNSUPPORTED_COMPORD_TYPE), InputError::WARN);
|
||||
BOOST_CHECK_EQUAL(ctx.get(ParseContext::PARSE_RANDOM_SLASH), InputError::IGNORE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user