Ticket #3603: fix_warnings.patch
File fix_warnings.patch, 13.3 KB (added by , 13 years ago) |
---|
-
libs/program_options/test/parsers_test.cpp
57 57 BOOST_CHECK(option.value.front() == value); 58 58 } 59 59 60 vector<string> sv(c har* array[], unsigned size)60 vector<string> sv(const char* array[], unsigned size) 61 61 { 62 62 vector<string> r; 63 63 for (unsigned i = 0; i < size; ++i) … … 113 113 ("baz", new untyped_value()) 114 114 ("plug*", new untyped_value()) 115 115 ; 116 c har* cmdline3_[] = { "--foo=12", "-f4", "--bar=11", "-b4",116 const char* cmdline3_[] = { "--foo=12", "-f4", "--bar=11", "-b4", 117 117 "--plug3=10"}; 118 118 vector<string> cmdline3 = sv(cmdline3_, 119 sizeof(cmdline3_)/sizeof(c mdline3_[0]));119 sizeof(cmdline3_)/sizeof(const char*)); 120 120 vector<option> a3 = 121 121 command_line_parser(cmdline3).options(desc).run().options; 122 122 … … 131 131 // Regression test: check that '0' as style is interpreted as 132 132 // 'default_style' 133 133 vector<option> a4 = 134 parse_command_line(5, cmdline3_, desc, 0, additional_parser).options; 134 parse_command_line(sizeof(cmdline3_)/sizeof(const char*), const_cast<char**>(cmdline3_), 135 desc, 0, additional_parser).options; 135 136 136 137 BOOST_CHECK_EQUAL(a4.size(), 4u); 137 138 check_value(a4[0], "foo", "4"); 138 139 check_value(a4[1], "bar", "11"); 139 140 140 141 // Check that we don't crash on empty values of type 'string' 141 c har* cmdline4[] = {"", "--open", ""};142 const char* cmdline4[] = {"", "--open", ""}; 142 143 options_description desc2; 143 144 desc2.add_options() 144 145 ("open", po::value<string>()) 145 146 ; 146 147 variables_map vm; 147 po::store(po::parse_command_line( 3, cmdline4, desc2), vm);148 po::store(po::parse_command_line(sizeof(cmdline4)/sizeof(const char*), const_cast<char**>(cmdline4), desc2), vm); 148 149 149 c har* cmdline5[] = {"", "-p7", "-o", "1", "2", "3", "-x8"};150 const char* cmdline5[] = {"", "-p7", "-o", "1", "2", "3", "-x8"}; 150 151 options_description desc3; 151 152 desc3.add_options() 152 153 (",p", po::value<string>()) … … 154 155 (",x", po::value<string>()) 155 156 ; 156 157 vector<option> a5 = 157 parse_command_line(7, cmdline5, desc3, 0, additional_parser).options; 158 parse_command_line(sizeof(cmdline5)/sizeof(const char*), const_cast<char**>(cmdline5), 159 desc3, 0, additional_parser).options; 158 160 BOOST_CHECK_EQUAL(a5.size(), 3u); 159 161 check_value(a5[0], "-p", "7"); 160 162 BOOST_REQUIRE(a5[1].value.size() == 3); … … 180 182 po::positional_options_description p; 181 183 p.add( "file", 1 ); 182 184 183 c har* cmdline6[] = {"", "-m", "token1", "token2", "--", "some_file"};185 const char* cmdline6[] = {"", "-m", "token1", "token2", "--", "some_file"}; 184 186 vector<option> a6 = 185 command_line_parser( 6, cmdline6).options(desc4).positional(p)187 command_line_parser(sizeof(cmdline6)/sizeof(const char*), const_cast<char**>(cmdline6)).options(desc4).positional(p) 186 188 .run().options; 187 189 BOOST_CHECK_EQUAL(a6.size(), 2u); 188 190 BOOST_REQUIRE(a6[0].value.size() == 2); … … 238 240 #if defined(_WIN32) && ! defined(__BORLANDC__) 239 241 _putenv("PO_TEST_FOO=1"); 240 242 #else 241 putenv( "PO_TEST_FOO=1");243 putenv(const_cast<char*>("PO_TEST_FOO=1")); 242 244 #endif 243 245 parsed_options p = parse_environment(desc, "PO_TEST_"); 244 246 … … 255 257 { 256 258 options_description desc; 257 259 258 c har* cmdline1_[] = { "--foo=12", "--bar", "1"};260 const char* cmdline1_[] = { "--foo=12", "--bar", "1"}; 259 261 vector<string> cmdline1 = sv(cmdline1_, 260 sizeof(cmdline1_)/sizeof(c mdline1_[0]));262 sizeof(cmdline1_)/sizeof(const char*)); 261 263 vector<option> a1 = 262 264 command_line_parser(cmdline1).options(desc).allow_unregistered().run() 263 265 .options; -
libs/program_options/test/test_convert.cpp
3 3 // (See accompanying file LICENSE_1_0.txt 4 4 // or copy at http://www.boost.org/LICENSE_1_0.txt) 5 5 6 #include <cstring> 6 7 #include <cassert> 7 8 #include <string> 8 9 #include <fstream> … … 38 39 std::wstring result; 39 40 40 41 41 std::mbstate_t state = {0}; 42 42 std::mbstate_t state; 43 memset(&state, 0, sizeof(std::mbstate_t)); 44 43 45 const char* from = s.data(); 44 46 const char* from_end = s.data() + s.size(); 45 47 // The interace of cvt is not really iterator-like, and it's -
libs/program_options/test/variable_map_test.cpp
20 20 21 21 #include "minitest.hpp" 22 22 23 vector<string> sv(c har* array[], unsigned size)23 vector<string> sv(const char* array[], unsigned size) 24 24 { 25 25 vector<string> r; 26 26 for (unsigned i = 0; i < size; ++i) … … 38 38 ("baz", new untyped_value()) 39 39 ("output,o", new untyped_value(), "") 40 40 ; 41 c har* cmdline3_[] = { "--foo='12'", "--bar=11", "-z3", "-ofoo" };41 const char* cmdline3_[] = { "--foo='12'", "--bar=11", "-z3", "-ofoo" }; 42 42 vector<string> cmdline3 = sv(cmdline3_, 43 sizeof(cmdline3_)/sizeof(c mdline3_[0]));43 sizeof(cmdline3_)/sizeof(const char*)); 44 44 parsed_options a3 = command_line_parser(cmdline3).options(desc).run(); 45 45 variables_map vm; 46 46 store(a3, vm); … … 58 58 ("zak", po::value<int>(&i), "") 59 59 ("opt", bool_switch(), ""); 60 60 61 c har* cmdline4_[] = { "--zee", "--zak=13" };61 const char* cmdline4_[] = { "--zee", "--zak=13" }; 62 62 vector<string> cmdline4 = sv(cmdline4_, 63 sizeof(cmdline4_)/sizeof(c mdline4_[0]));63 sizeof(cmdline4_)/sizeof(const char*)); 64 64 parsed_options a4 = command_line_parser(cmdline4).options(desc).run(); 65 65 66 66 variables_map vm2; … … 78 78 ("voo", po::value<string>()) 79 79 ("iii", po::value<int>()->default_value(123)) 80 80 ; 81 c har* cmdline5_[] = {"--voo=1" };81 const char* cmdline5_[] = { "--voo=1" }; 82 82 vector<string> cmdline5 = sv(cmdline5_, 83 sizeof(cmdline5_)/sizeof(c mdline5_[0]));83 sizeof(cmdline5_)/sizeof(const char*)); 84 84 parsed_options a5 = command_line_parser(cmdline5).options(desc2).run(); 85 85 86 86 variables_map vm3; … … 100 100 ; 101 101 /* The -m option is implicit. It does not have value in inside the token, 102 102 and we should not grab the next token. */ 103 c har* cmdline6_[] = { "--imp=1", "-m", "--foo=1" };103 const char* cmdline6_[] = { "--imp=1", "-m", "--foo=1" }; 104 104 vector<string> cmdline6 = sv(cmdline6_, 105 sizeof(cmdline6_)/sizeof(c mdline6_[0]));105 sizeof(cmdline6_)/sizeof(const char*)); 106 106 parsed_options a6 = command_line_parser(cmdline6).options(desc3).run(); 107 107 108 108 variables_map vm4; … … 194 194 ("include", po::value< vector<int> >()->composing()) 195 195 ; 196 196 197 c har* cmdline1_[] = { "--first=1", "--aux=10", "--first=3", "--include=1" };197 const char* cmdline1_[] = { "--first=1", "--aux=10", "--first=3", "--include=1" }; 198 198 vector<string> cmdline1 = sv(cmdline1_, 199 sizeof(cmdline1_)/sizeof(c mdline1_[0]));199 sizeof(cmdline1_)/sizeof(const char*)); 200 200 201 201 parsed_options p1 = command_line_parser(cmdline1).options(desc).run(); 202 202 203 c har* cmdline2_[] = { "--first=12", "--second=7", "--include=7" };203 const char* cmdline2_[] = { "--first=12", "--second=7", "--include=7" }; 204 204 vector<string> cmdline2 = sv(cmdline2_, 205 sizeof(cmdline2_)/sizeof(c mdline2_[0]));205 sizeof(cmdline2_)/sizeof(const char*)); 206 206 207 207 parsed_options p2 = command_line_parser(cmdline2).options(desc).run(); 208 208 -
libs/program_options/test/unicode_test.cpp
88 88 BOOST_CHECK(vm["foo"].as<wstring>() == L"\x044F"); 89 89 } 90 90 91 92 vector<wstring> sv(wchar_t* array[], unsigned size) 91 vector<wstring> sv(const wchar_t* array[], unsigned size) 93 92 { 94 93 vector<wstring> r; 95 94 for (unsigned i = 0; i < size; ++i) … … 115 114 ("plug*", new untyped_value()) 116 115 ; 117 116 118 wchar_t* cmdline4_[] = { L"--foo=1\u0FF52", L"-f4", L"--bar=11",117 const wchar_t* cmdline4_[] = { L"--foo=1\u0FF52", L"-f4", L"--bar=11", 119 118 L"-b4", L"--plug3=10"}; 120 119 vector<wstring> cmdline4 = sv(cmdline4_, 121 120 sizeof(cmdline4_)/sizeof(cmdline4_[0])); -
libs/program_options/test/cmdline_test.cpp
183 183 {"--bar", s_missing_parameter, ""}, 184 184 185 185 {"--bar=123", s_success, "bar:123"}, 186 {0 }186 {0, 0, 0} 187 187 }; 188 188 test_cmdline("foo bar=", style, test_cases1); 189 189 … … 198 198 // considered a value, even though it looks like 199 199 // an option. 200 200 {"--bar --foo", s_success, "bar:--foo"}, 201 {0 }201 {0, 0, 0} 202 202 }; 203 203 test_cmdline("foo bar=", style, test_cases2); 204 204 style = cmdline::style_t( … … 208 208 test_case test_cases3[] = { 209 209 {"--bar=10", s_success, "bar:10"}, 210 210 {"--bar 11", s_success, "bar:11"}, 211 {0 }211 {0, 0, 0} 212 212 }; 213 213 test_cmdline("foo bar=", style, test_cases3); 214 214 … … 226 226 {"--bar=Ab", s_success, "bar:Ab"}, 227 227 {"--Bar=ab", s_success, "bar:ab"}, 228 228 {"--giz", s_success, "Giz:"}, 229 {0 }229 {0, 0, 0} 230 230 }; 231 231 test_cmdline("foo bar= baz? Giz", style, test_cases4); 232 232 #endif … … 249 249 {"-f14", s_success, "-f:14"}, 250 250 {"-g -f1", s_success, "-g: -f:1"}, 251 251 {"-f", s_missing_parameter, ""}, 252 {0 }252 {0, 0, 0} 253 253 }; 254 254 test_cmdline(",d ,f= ,g", style, test_cases1); 255 255 … … 263 263 {"-f", s_missing_parameter, ""}, 264 264 {"-f /foo", s_success, "-f:/foo"}, 265 265 {"-f -d", s_success, "-f:-d"}, 266 {0 }266 {0, 0, 0} 267 267 }; 268 268 test_cmdline(",d ,f=", style, test_cases2); 269 269 … … 275 275 {"-f10", s_success, "-f:10"}, 276 276 {"-f 10", s_success, "-f:10"}, 277 277 {"-f -d", s_success, "-f:-d"}, 278 {0 }278 {0, 0, 0} 279 279 }; 280 280 test_cmdline(",d ,f=", style, test_cases3); 281 281 … … 291 291 //{"-d12", s_extra_parameter, ""}, 292 292 {"-f12", s_success, "-f:12"}, 293 293 {"-fe", s_success, "-f:e"}, 294 {0 }294 {0, 0, 0} 295 295 }; 296 296 test_cmdline(",d ,f= ,e", style, test_cases4); 297 297 … … 313 313 {"/d13", s_extra_parameter, ""}, 314 314 {"/f14", s_success, "-f:14"}, 315 315 {"/f", s_missing_parameter, ""}, 316 {0 }316 {0, 0, 0} 317 317 }; 318 318 test_cmdline(",d ,f=", style, test_cases1); 319 319 … … 325 325 test_case test_cases2[] = { 326 326 {"/de", s_extra_parameter, ""}, 327 327 {"/fe", s_success, "-f:e"}, 328 {0 }328 {0, 0, 0} 329 329 }; 330 330 test_cmdline(",d ,f= ,e", style, test_cases2); 331 331 … … 347 347 {"-foo -f", s_success, "foo: foo:"}, 348 348 {"-goo=x -gy", s_success, "goo:x goo:y"}, 349 349 {"-bee=x -by", s_success, "bee:x bee:y"}, 350 {0 }350 {0, 0, 0} 351 351 }; 352 352 test_cmdline("foo,f goo,g= bee,b?", style, test_cases1); 353 353 … … 355 355 test_case test_cases2[] = { 356 356 {"/foo -f", s_success, "foo: foo:"}, 357 357 {"/goo=x", s_success, "goo:x"}, 358 {0 }358 {0, 0, 0} 359 359 }; 360 360 test_cmdline("foo,f goo,g= bee,b?", style, test_cases2); 361 361 } … … 376 376 {"--opt", s_ambiguous_option, ""}, 377 377 {"--f=1", s_success, "foo:1"}, 378 378 {"-far", s_success, "foo:ar"}, 379 {0 }379 {0, 0, 0} 380 380 }; 381 381 test_cmdline("opt123 opt56 foo,f=", style, test_cases1); 382 382 } … … 394 394 test_case test_cases1[] = { 395 395 {"-f file -gx file2", s_success, "-f: file -g:x file2"}, 396 396 {"-f - -gx - -- -e", s_success, "-f: - -g:x - -e"}, 397 {0 }397 {0, 0, 0} 398 398 }; 399 399 test_cmdline(",f ,g= ,e", style, test_cases1); 400 400 … … 407 407 408 408 test_case test_cases2[] = { 409 409 {"-f - -gx - -- -e", s_success, "-f: - -g:x - -e"}, 410 {0 }410 {0, 0, 0} 411 411 }; 412 412 test_cmdline(",f ,g= ,e", style, test_cases2); 413 413 } … … 425 425 426 426 test_case test_cases1[] = { 427 427 {"--foo.bar=12", s_success, "foo.bar:12"}, 428 {0 }428 {0, 0, 0} 429 429 }; 430 430 431 431 test_cmdline("foo*=", style, test_cases1); … … 599 599 // It's not clear yet, so I'm leaving the decision till later. 600 600 } 601 601 602 int main(int ac, char* av[])602 int main(int /*ac*/, char** /*av*/) 603 603 { 604 604 test_long_options(); 605 605 test_short_options();