diff --git a/opm/parser/eclipse/Utility/tests/FunctionalTests.cpp b/opm/parser/eclipse/Utility/tests/FunctionalTests.cpp index 8f76e5be3..3b6c560a0 100644 --- a/opm/parser/eclipse/Utility/tests/FunctionalTests.cpp +++ b/opm/parser/eclipse/Utility/tests/FunctionalTests.cpp @@ -18,17 +18,52 @@ */ #define BOOST_TEST_MODULE FunctionalTests +#include #include +#include #include #include #include #include -#include + using namespace Opm; + +BOOST_AUTO_TEST_CASE(TestMap) { + std::map m = { {"C", 3}, {"B" , 2} , {"A" , 1}}; + std::vector keys_expected = {"A" , "B" , "C"}; + auto keys = fun::map( [] ( const std::pair& pair) { return pair.first; } , m); + + BOOST_CHECK_EQUAL_COLLECTIONS(keys.begin(), keys.end(), + keys_expected.begin(), keys_expected.end()); +} + + +BOOST_AUTO_TEST_CASE(TestConcat) { + std::vector> vector_of_vectors = {{1},{2,2},{3,3,3}}; + auto conc = fun::concat( std::move(vector_of_vectors) ); + std::vector expected = {1,2,2,3,3,3}; + + BOOST_CHECK_EQUAL_COLLECTIONS(conc.begin(), conc.end(), + expected.begin(), expected.end()); +} + + +BOOST_AUTO_TEST_CASE(TestConcatMap) { + std::vector input = {1,2,3}; + auto conc = fun::concat( fun::map( []( int x ) { return std::vector( x,x ); } , input)); + + std::vector expected = {1,2,2,3,3,3}; + BOOST_CHECK_EQUAL_COLLECTIONS(conc.begin(), conc.end(), + expected.begin(), expected.end()); + +} + + + BOOST_AUTO_TEST_CASE(iotaEqualCollections) { std::vector< int > vec( 5 );