|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57535 - trunk/libs/program_options/test
From: ghost_at_[hidden]
Date: 2009-11-10 01:59:57
Author: vladimir_prus
Date: 2009-11-10 01:59:54 EST (Tue, 10 Nov 2009)
New Revision: 57535
URL: http://svn.boost.org/trac/boost/changeset/57535
Log:
Fix warnings.
Addresses #3603.
Patch from Sascha Ochsenknecht.
Text files modified:
trunk/libs/program_options/test/cmdline_test.cpp | 34 +++++++++++++++++-----------------
trunk/libs/program_options/test/parsers_test.cpp | 28 +++++++++++++++-------------
trunk/libs/program_options/test/test_convert.cpp | 6 ++++--
trunk/libs/program_options/test/unicode_test.cpp | 5 ++---
trunk/libs/program_options/test/variable_map_test.cpp | 26 +++++++++++++-------------
5 files changed, 51 insertions(+), 48 deletions(-)
Modified: trunk/libs/program_options/test/cmdline_test.cpp
==============================================================================
--- trunk/libs/program_options/test/cmdline_test.cpp (original)
+++ trunk/libs/program_options/test/cmdline_test.cpp 2009-11-10 01:59:54 EST (Tue, 10 Nov 2009)
@@ -183,7 +183,7 @@
{"--bar", s_missing_parameter, ""},
{"--bar=123", s_success, "bar:123"},
- {0}
+ {0, 0, 0}
};
test_cmdline("foo bar=", style, test_cases1);
@@ -198,7 +198,7 @@
// considered a value, even though it looks like
// an option.
{"--bar --foo", s_success, "bar:--foo"},
- {0}
+ {0, 0, 0}
};
test_cmdline("foo bar=", style, test_cases2);
style = cmdline::style_t(
@@ -208,7 +208,7 @@
test_case test_cases3[] = {
{"--bar=10", s_success, "bar:10"},
{"--bar 11", s_success, "bar:11"},
- {0}
+ {0, 0, 0}
};
test_cmdline("foo bar=", style, test_cases3);
@@ -226,7 +226,7 @@
{"--bar=Ab", s_success, "bar:Ab"},
{"--Bar=ab", s_success, "bar:ab"},
{"--giz", s_success, "Giz:"},
- {0}
+ {0, 0, 0}
};
test_cmdline("foo bar= baz? Giz", style, test_cases4);
#endif
@@ -249,7 +249,7 @@
{"-f14", s_success, "-f:14"},
{"-g -f1", s_success, "-g: -f:1"},
{"-f", s_missing_parameter, ""},
- {0}
+ {0, 0, 0}
};
test_cmdline(",d ,f= ,g", style, test_cases1);
@@ -263,7 +263,7 @@
{"-f", s_missing_parameter, ""},
{"-f /foo", s_success, "-f:/foo"},
{"-f -d", s_success, "-f:-d"},
- {0}
+ {0, 0, 0}
};
test_cmdline(",d ,f=", style, test_cases2);
@@ -275,7 +275,7 @@
{"-f10", s_success, "-f:10"},
{"-f 10", s_success, "-f:10"},
{"-f -d", s_success, "-f:-d"},
- {0}
+ {0, 0, 0}
};
test_cmdline(",d ,f=", style, test_cases3);
@@ -291,7 +291,7 @@
//{"-d12", s_extra_parameter, ""},
{"-f12", s_success, "-f:12"},
{"-fe", s_success, "-f:e"},
- {0}
+ {0, 0, 0}
};
test_cmdline(",d ,f= ,e", style, test_cases4);
@@ -313,7 +313,7 @@
{"/d13", s_extra_parameter, ""},
{"/f14", s_success, "-f:14"},
{"/f", s_missing_parameter, ""},
- {0}
+ {0, 0, 0}
};
test_cmdline(",d ,f=", style, test_cases1);
@@ -325,7 +325,7 @@
test_case test_cases2[] = {
{"/de", s_extra_parameter, ""},
{"/fe", s_success, "-f:e"},
- {0}
+ {0, 0, 0}
};
test_cmdline(",d ,f= ,e", style, test_cases2);
@@ -347,7 +347,7 @@
{"-foo -f", s_success, "foo: foo:"},
{"-goo=x -gy", s_success, "goo:x goo:y"},
{"-bee=x -by", s_success, "bee:x bee:y"},
- {0}
+ {0, 0, 0}
};
test_cmdline("foo,f goo,g= bee,b?", style, test_cases1);
@@ -355,7 +355,7 @@
test_case test_cases2[] = {
{"/foo -f", s_success, "foo: foo:"},
{"/goo=x", s_success, "goo:x"},
- {0}
+ {0, 0, 0}
};
test_cmdline("foo,f goo,g= bee,b?", style, test_cases2);
}
@@ -376,7 +376,7 @@
{"--opt", s_ambiguous_option, ""},
{"--f=1", s_success, "foo:1"},
{"-far", s_success, "foo:ar"},
- {0}
+ {0, 0, 0}
};
test_cmdline("opt123 opt56 foo,f=", style, test_cases1);
}
@@ -394,7 +394,7 @@
test_case test_cases1[] = {
{"-f file -gx file2", s_success, "-f: file -g:x file2"},
{"-f - -gx - -- -e", s_success, "-f: - -g:x - -e"},
- {0}
+ {0, 0, 0}
};
test_cmdline(",f ,g= ,e", style, test_cases1);
@@ -407,7 +407,7 @@
test_case test_cases2[] = {
{"-f - -gx - -- -e", s_success, "-f: - -g:x - -e"},
- {0}
+ {0, 0, 0}
};
test_cmdline(",f ,g= ,e", style, test_cases2);
}
@@ -425,7 +425,7 @@
test_case test_cases1[] = {
{"--foo.bar=12", s_success, "foo.bar:12"},
- {0}
+ {0, 0, 0}
};
test_cmdline("foo*=", style, test_cases1);
@@ -599,7 +599,7 @@
// It's not clear yet, so I'm leaving the decision till later.
}
-int main(int ac, char* av[])
+int main(int /*ac*/, char** /*av*/)
{
test_long_options();
test_short_options();
Modified: trunk/libs/program_options/test/parsers_test.cpp
==============================================================================
--- trunk/libs/program_options/test/parsers_test.cpp (original)
+++ trunk/libs/program_options/test/parsers_test.cpp 2009-11-10 01:59:54 EST (Tue, 10 Nov 2009)
@@ -57,7 +57,7 @@
BOOST_CHECK(option.value.front() == value);
}
-vector<string> sv(char* array[], unsigned size)
+vector<string> sv(const char* array[], unsigned size)
{
vector<string> r;
for (unsigned i = 0; i < size; ++i)
@@ -113,10 +113,10 @@
("baz", new untyped_value())
("plug*", new untyped_value())
;
- char* cmdline3_[] = { "--foo=12", "-f4", "--bar=11", "-b4",
+ const char* cmdline3_[] = { "--foo=12", "-f4", "--bar=11", "-b4",
"--plug3=10"};
vector<string> cmdline3 = sv(cmdline3_,
- sizeof(cmdline3_)/sizeof(cmdline3_[0]));
+ sizeof(cmdline3_)/sizeof(const char*));
vector<option> a3 =
command_line_parser(cmdline3).options(desc).run().options;
@@ -131,22 +131,23 @@
// Regression test: check that '0' as style is interpreted as
// 'default_style'
vector<option> a4 =
- parse_command_line(5, cmdline3_, desc, 0, additional_parser).options;
+ parse_command_line(sizeof(cmdline3_)/sizeof(const char*), const_cast<char**>(cmdline3_),
+ desc, 0, additional_parser).options;
BOOST_CHECK_EQUAL(a4.size(), 4u);
check_value(a4[0], "foo", "4");
check_value(a4[1], "bar", "11");
// Check that we don't crash on empty values of type 'string'
- char* cmdline4[] = {"", "--open", ""};
+ const char* cmdline4[] = {"", "--open", ""};
options_description desc2;
desc2.add_options()
("open", po::value<string>())
;
variables_map vm;
- po::store(po::parse_command_line(3, cmdline4, desc2), vm);
+ po::store(po::parse_command_line(sizeof(cmdline4)/sizeof(const char*), const_cast<char**>(cmdline4), desc2), vm);
- char* cmdline5[] = {"", "-p7", "-o", "1", "2", "3", "-x8"};
+ const char* cmdline5[] = {"", "-p7", "-o", "1", "2", "3", "-x8"};
options_description desc3;
desc3.add_options()
(",p", po::value<string>())
@@ -154,7 +155,8 @@
(",x", po::value<string>())
;
vector<option> a5 =
- parse_command_line(7, cmdline5, desc3, 0, additional_parser).options;
+ parse_command_line(sizeof(cmdline5)/sizeof(const char*), const_cast<char**>(cmdline5),
+ desc3, 0, additional_parser).options;
BOOST_CHECK_EQUAL(a5.size(), 3u);
check_value(a5[0], "-p", "7");
BOOST_REQUIRE(a5[1].value.size() == 3);
@@ -180,9 +182,9 @@
po::positional_options_description p;
p.add( "file", 1 );
- char* cmdline6[] = {"", "-m", "token1", "token2", "--", "some_file"};
+ const char* cmdline6[] = {"", "-m", "token1", "token2", "--", "some_file"};
vector<option> a6 =
- command_line_parser(6, cmdline6).options(desc4).positional(p)
+ command_line_parser(sizeof(cmdline6)/sizeof(const char*), const_cast<char**>(cmdline6)).options(desc4).positional(p)
.run().options;
BOOST_CHECK_EQUAL(a6.size(), 2u);
BOOST_REQUIRE(a6[0].value.size() == 2);
@@ -238,7 +240,7 @@
#if defined(_WIN32) && ! defined(__BORLANDC__)
_putenv("PO_TEST_FOO=1");
#else
- putenv("PO_TEST_FOO=1");
+ putenv(const_cast<char*>("PO_TEST_FOO=1"));
#endif
parsed_options p = parse_environment(desc, "PO_TEST_");
@@ -255,9 +257,9 @@
{
options_description desc;
- char* cmdline1_[] = { "--foo=12", "--bar", "1"};
+ const char* cmdline1_[] = { "--foo=12", "--bar", "1"};
vector<string> cmdline1 = sv(cmdline1_,
- sizeof(cmdline1_)/sizeof(cmdline1_[0]));
+ sizeof(cmdline1_)/sizeof(const char*));
vector<option> a1 =
command_line_parser(cmdline1).options(desc).allow_unregistered().run()
.options;
Modified: trunk/libs/program_options/test/test_convert.cpp
==============================================================================
--- trunk/libs/program_options/test/test_convert.cpp (original)
+++ trunk/libs/program_options/test/test_convert.cpp 2009-11-10 01:59:54 EST (Tue, 10 Nov 2009)
@@ -3,6 +3,7 @@
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
+#include <cstring>
#include <cassert>
#include <string>
#include <fstream>
@@ -38,8 +39,9 @@
std::wstring result;
- std::mbstate_t state = {0};
-
+ std::mbstate_t state;
+ memset(&state, 0, sizeof(std::mbstate_t));
+
const char* from = s.data();
const char* from_end = s.data() + s.size();
// The interace of cvt is not really iterator-like, and it's
Modified: trunk/libs/program_options/test/unicode_test.cpp
==============================================================================
--- trunk/libs/program_options/test/unicode_test.cpp (original)
+++ trunk/libs/program_options/test/unicode_test.cpp 2009-11-10 01:59:54 EST (Tue, 10 Nov 2009)
@@ -88,8 +88,7 @@
BOOST_CHECK(vm["foo"].as<wstring>() == L"\x044F");
}
-
-vector<wstring> sv(wchar_t* array[], unsigned size)
+vector<wstring> sv(const wchar_t* array[], unsigned size)
{
vector<wstring> r;
for (unsigned i = 0; i < size; ++i)
@@ -115,7 +114,7 @@
("plug*", new untyped_value())
;
- wchar_t* cmdline4_[] = { L"--foo=1\u0FF52", L"-f4", L"--bar=11",
+ const wchar_t* cmdline4_[] = { L"--foo=1\u0FF52", L"-f4", L"--bar=11",
L"-b4", L"--plug3=10"};
vector<wstring> cmdline4 = sv(cmdline4_,
sizeof(cmdline4_)/sizeof(cmdline4_[0]));
Modified: trunk/libs/program_options/test/variable_map_test.cpp
==============================================================================
--- trunk/libs/program_options/test/variable_map_test.cpp (original)
+++ trunk/libs/program_options/test/variable_map_test.cpp 2009-11-10 01:59:54 EST (Tue, 10 Nov 2009)
@@ -20,7 +20,7 @@
#include "minitest.hpp"
-vector<string> sv(char* array[], unsigned size)
+vector<string> sv(const char* array[], unsigned size)
{
vector<string> r;
for (unsigned i = 0; i < size; ++i)
@@ -38,9 +38,9 @@
("baz", new untyped_value())
("output,o", new untyped_value(), "")
;
- char* cmdline3_[] = { "--foo='12'", "--bar=11", "-z3", "-ofoo" };
+ const char* cmdline3_[] = { "--foo='12'", "--bar=11", "-z3", "-ofoo" };
vector<string> cmdline3 = sv(cmdline3_,
- sizeof(cmdline3_)/sizeof(cmdline3_[0]));
+ sizeof(cmdline3_)/sizeof(const char*));
parsed_options a3 = command_line_parser(cmdline3).options(desc).run();
variables_map vm;
store(a3, vm);
@@ -58,9 +58,9 @@
("zak", po::value<int>(&i), "")
("opt", bool_switch(), "");
- char* cmdline4_[] = { "--zee", "--zak=13" };
+ const char* cmdline4_[] = { "--zee", "--zak=13" };
vector<string> cmdline4 = sv(cmdline4_,
- sizeof(cmdline4_)/sizeof(cmdline4_[0]));
+ sizeof(cmdline4_)/sizeof(const char*));
parsed_options a4 = command_line_parser(cmdline4).options(desc).run();
variables_map vm2;
@@ -78,9 +78,9 @@
("voo", po::value<string>())
("iii", po::value<int>()->default_value(123))
;
- char* cmdline5_[] = { "--voo=1" };
+ const char* cmdline5_[] = { "--voo=1" };
vector<string> cmdline5 = sv(cmdline5_,
- sizeof(cmdline5_)/sizeof(cmdline5_[0]));
+ sizeof(cmdline5_)/sizeof(const char*));
parsed_options a5 = command_line_parser(cmdline5).options(desc2).run();
variables_map vm3;
@@ -100,9 +100,9 @@
;
/* The -m option is implicit. It does not have value in inside the token,
and we should not grab the next token. */
- char* cmdline6_[] = { "--imp=1", "-m", "--foo=1" };
+ const char* cmdline6_[] = { "--imp=1", "-m", "--foo=1" };
vector<string> cmdline6 = sv(cmdline6_,
- sizeof(cmdline6_)/sizeof(cmdline6_[0]));
+ sizeof(cmdline6_)/sizeof(const char*));
parsed_options a6 = command_line_parser(cmdline6).options(desc3).run();
variables_map vm4;
@@ -194,15 +194,15 @@
("include", po::value< vector<int> >()->composing())
;
- char* cmdline1_[] = { "--first=1", "--aux=10", "--first=3", "--include=1" };
+ const char* cmdline1_[] = { "--first=1", "--aux=10", "--first=3", "--include=1" };
vector<string> cmdline1 = sv(cmdline1_,
- sizeof(cmdline1_)/sizeof(cmdline1_[0]));
+ sizeof(cmdline1_)/sizeof(const char*));
parsed_options p1 = command_line_parser(cmdline1).options(desc).run();
- char* cmdline2_[] = { "--first=12", "--second=7", "--include=7" };
+ const char* cmdline2_[] = { "--first=12", "--second=7", "--include=7" };
vector<string> cmdline2 = sv(cmdline2_,
- sizeof(cmdline2_)/sizeof(cmdline2_[0]));
+ sizeof(cmdline2_)/sizeof(const char*));
parsed_options p2 = command_line_parser(cmdline2).options(desc).run();
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk