diff --git a/python/cxx/deck.cpp b/python/cxx/deck.cpp index d6024fc16..2014890c7 100644 --- a/python/cxx/deck.cpp +++ b/python/cxx/deck.cpp @@ -35,6 +35,11 @@ namespace { return deck.getKeyword(index); } + //This adds a keyword by copy + void addKeyword(Deck& deck, const DeckKeyword kw) { + deck.addKeyword(kw); + } + } @@ -59,6 +64,7 @@ void python::common::export_Deck(py::module &module) { } ) .def( "count", &count ) + .def( "add", &addKeyword) ; } diff --git a/python/tests/test_parser.py b/python/tests/test_parser.py index efaf16d89..cc894d592 100644 --- a/python/tests/test_parser.py +++ b/python/tests/test_parser.py @@ -151,6 +151,10 @@ FIPNUM si_array = zcorn_kw.get_SI_array() self.assertAlmostEqual( si_array[0], 1.1 * unit_foot ) self.assertAlmostEqual( si_array[2], 3.3 * unit_foot ) + + assert( not( "ZCORN" in deck ) ) + deck.add( zcorn_kw ) + assert( "ZCORN" in deck ) diff --git a/tests/parser/EmbeddedPython.cpp b/tests/parser/EmbeddedPython.cpp index 537a4fb9c..1d7f7f670 100644 --- a/tests/parser/EmbeddedPython.cpp +++ b/tests/parser/EmbeddedPython.cpp @@ -49,8 +49,11 @@ BOOST_AUTO_TEST_CASE(INSTANTIATE) { std::string python_code = R"( print('Parser: {}'.format(context.parser)) print('Deck: {}'.format(context.deck)) +kw = context.DeckKeyword( context.parser['FIELD'] ) +context.deck.add(kw) )"; BOOST_CHECK_NO_THROW( python.exec(python_code, parser, deck)); + BOOST_CHECK( deck.hasKeyword("FIELD") ); } #endif