From d4e7ad3ea1a6be629405549e8ad1c0f5c5a00ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 14 Apr 2015 15:58:37 +0200 Subject: [PATCH] Make test argc/argv data mimic POSIX correct data. --- tests/test_param.cpp | 48 ++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/tests/test_param.cpp b/tests/test_param.cpp index 9a04ef9a..972b20db 100644 --- a/tests/test_param.cpp +++ b/tests/test_param.cpp @@ -47,22 +47,24 @@ #include #include #include +#include using namespace Opm; BOOST_AUTO_TEST_CASE(commandline_syntax_init) { typedef const char* cp; - cp argv[] = { "program_command", - "topitem=somestring", - "/slashtopitem=anotherstring", - "/group/item=1", - "/group/anotheritem=2", - "/group/subgroup/item=3", - "/group/subgroup/anotheritem=4", - "/group/item=overridingstring" }; - const std::size_t argc = sizeof(argv)/sizeof(argv[0]); - parameter::ParameterGroup p(argc, argv); + std::vector argv = { "program_command", + "topitem=somestring", + "/slashtopitem=anotherstring", + "/group/item=1", + "/group/anotheritem=2", + "/group/subgroup/item=3", + "/group/subgroup/anotheritem=4", + "/group/item=overridingstring", + 0 }; + const std::size_t argc = argv.size() - 1; + parameter::ParameterGroup p(argc, argv.data()); BOOST_CHECK(p.get("topitem") == "somestring"); std::ostringstream os; p.writeParamToStream(os); @@ -84,12 +86,13 @@ BOOST_AUTO_TEST_CASE(commandline_syntax_init) BOOST_AUTO_TEST_CASE(xml_syntax_init) { typedef const char* cp; - cp argv[] = { "program_command", - "testdata.xml", - "/group/item=overridingstring", - "unhandledargument" }; - const std::size_t argc = sizeof(argv)/sizeof(argv[0]); - parameter::ParameterGroup p(argc, argv, false); + std::vector argv = { "program_command", + "testdata.xml", + "/group/item=overridingstring", + "unhandledargument", + 0}; + const std::size_t argc = argv.size() - 1; + parameter::ParameterGroup p(argc, argv.data(), false); BOOST_CHECK(p.get("topitem") == "somestring"); std::ostringstream os; p.writeParamToStream(os); @@ -111,10 +114,11 @@ BOOST_AUTO_TEST_CASE(xml_syntax_init) BOOST_AUTO_TEST_CASE(failing_strict_xml_syntax_init) { typedef const char* cp; - cp argv[] = { "program_command", - "testdata.xml", - "/group/item=overridingstring", - "unhandledargument" }; - const std::size_t argc = sizeof(argv)/sizeof(argv[0]); - BOOST_CHECK_THROW(parameter::ParameterGroup p(argc, argv), std::runtime_error); + std::vector argv = { "program_command", + "testdata.xml", + "/group/item=overridingstring", + "unhandledargument", + 0 }; + const std::size_t argc = argv.size() - 1; + BOOST_CHECK_THROW(parameter::ParameterGroup p(argc, argv.data()), std::runtime_error); }