Make test argc/argv data mimic POSIX correct data.
This commit is contained in:
parent
37904a3e74
commit
d4e7ad3ea1
@ -47,22 +47,24 @@
|
|||||||
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
#include <opm/core/utility/parameters/ParameterGroup.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace Opm;
|
using namespace Opm;
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(commandline_syntax_init)
|
BOOST_AUTO_TEST_CASE(commandline_syntax_init)
|
||||||
{
|
{
|
||||||
typedef const char* cp;
|
typedef const char* cp;
|
||||||
cp argv[] = { "program_command",
|
std::vector<cp> argv = { "program_command",
|
||||||
"topitem=somestring",
|
"topitem=somestring",
|
||||||
"/slashtopitem=anotherstring",
|
"/slashtopitem=anotherstring",
|
||||||
"/group/item=1",
|
"/group/item=1",
|
||||||
"/group/anotheritem=2",
|
"/group/anotheritem=2",
|
||||||
"/group/subgroup/item=3",
|
"/group/subgroup/item=3",
|
||||||
"/group/subgroup/anotheritem=4",
|
"/group/subgroup/anotheritem=4",
|
||||||
"/group/item=overridingstring" };
|
"/group/item=overridingstring",
|
||||||
const std::size_t argc = sizeof(argv)/sizeof(argv[0]);
|
0 };
|
||||||
parameter::ParameterGroup p(argc, argv);
|
const std::size_t argc = argv.size() - 1;
|
||||||
|
parameter::ParameterGroup p(argc, argv.data());
|
||||||
BOOST_CHECK(p.get<std::string>("topitem") == "somestring");
|
BOOST_CHECK(p.get<std::string>("topitem") == "somestring");
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
p.writeParamToStream(os);
|
p.writeParamToStream(os);
|
||||||
@ -84,12 +86,13 @@ BOOST_AUTO_TEST_CASE(commandline_syntax_init)
|
|||||||
BOOST_AUTO_TEST_CASE(xml_syntax_init)
|
BOOST_AUTO_TEST_CASE(xml_syntax_init)
|
||||||
{
|
{
|
||||||
typedef const char* cp;
|
typedef const char* cp;
|
||||||
cp argv[] = { "program_command",
|
std::vector<cp> argv = { "program_command",
|
||||||
"testdata.xml",
|
"testdata.xml",
|
||||||
"/group/item=overridingstring",
|
"/group/item=overridingstring",
|
||||||
"unhandledargument" };
|
"unhandledargument",
|
||||||
const std::size_t argc = sizeof(argv)/sizeof(argv[0]);
|
0};
|
||||||
parameter::ParameterGroup p(argc, argv, false);
|
const std::size_t argc = argv.size() - 1;
|
||||||
|
parameter::ParameterGroup p(argc, argv.data(), false);
|
||||||
BOOST_CHECK(p.get<std::string>("topitem") == "somestring");
|
BOOST_CHECK(p.get<std::string>("topitem") == "somestring");
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
p.writeParamToStream(os);
|
p.writeParamToStream(os);
|
||||||
@ -111,10 +114,11 @@ BOOST_AUTO_TEST_CASE(xml_syntax_init)
|
|||||||
BOOST_AUTO_TEST_CASE(failing_strict_xml_syntax_init)
|
BOOST_AUTO_TEST_CASE(failing_strict_xml_syntax_init)
|
||||||
{
|
{
|
||||||
typedef const char* cp;
|
typedef const char* cp;
|
||||||
cp argv[] = { "program_command",
|
std::vector<cp> argv = { "program_command",
|
||||||
"testdata.xml",
|
"testdata.xml",
|
||||||
"/group/item=overridingstring",
|
"/group/item=overridingstring",
|
||||||
"unhandledargument" };
|
"unhandledargument",
|
||||||
const std::size_t argc = sizeof(argv)/sizeof(argv[0]);
|
0 };
|
||||||
BOOST_CHECK_THROW(parameter::ParameterGroup p(argc, argv), std::runtime_error);
|
const std::size_t argc = argv.size() - 1;
|
||||||
|
BOOST_CHECK_THROW(parameter::ParameterGroup p(argc, argv.data()), std::runtime_error);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user