@@ -258,16 +258,52 @@ BOOST_AUTO_TEST_CASE(util_GetBoolArgEdgeCases)
258258{
259259 // Test some awful edge cases that hopefully no user will ever exercise.
260260 TestArgsManager testArgs;
261+
262+ // Params test
261263 const char *argv_test[] = {" ignored" , " -nofoo" , " -foo" , " -nobar=0" };
262264 testArgs.ParseParameters (4 , (char **)argv_test);
263265
264266 // This was passed twice, second one overrides the negative setting.
265267 BOOST_CHECK (!testArgs.IsArgNegated (" -foo" ));
266- BOOST_CHECK (testArgs.GetBoolArg (" -foo" , false ) == true );
268+ BOOST_CHECK (testArgs.GetArg (" -foo" , " xxx " ) == " " );
267269
268270 // A double negative is a positive.
269271 BOOST_CHECK (testArgs.IsArgNegated (" -bar" ));
270- BOOST_CHECK (testArgs.GetBoolArg (" -bar" , false ) == true );
272+ BOOST_CHECK (testArgs.GetArg (" -bar" , " xxx" ) == " 1" );
273+
274+ // Config test
275+ const char *conf_test = " nofoo=1\n foo=1\n nobar=0\n " ;
276+ testArgs.ParseParameters (1 , (char **)argv_test);
277+ testArgs.ReadConfigString (conf_test);
278+
279+ // This was passed twice, second one overrides the negative setting,
280+ // but not the value.
281+ BOOST_CHECK (!testArgs.IsArgNegated (" -foo" ));
282+ BOOST_CHECK (testArgs.GetArg (" -foo" , " xxx" ) == " 0" );
283+
284+ // A double negative is a positive.
285+ BOOST_CHECK (testArgs.IsArgNegated (" -bar" ));
286+ BOOST_CHECK (testArgs.GetArg (" -bar" , " xxx" ) == " 1" );
287+
288+ // Combined test
289+ const char *combo_test_args[] = {" ignored" , " -nofoo" , " -bar" };
290+ const char *combo_test_conf = " foo=1\n nobar=1\n " ;
291+ testArgs.ParseParameters (3 , (char **)combo_test_args);
292+ testArgs.ReadConfigString (combo_test_conf);
293+
294+ // Command line overrides, but doesn't erase old setting
295+ BOOST_CHECK (!testArgs.IsArgNegated (" -foo" ));
296+ BOOST_CHECK (testArgs.GetArg (" -foo" , " xxx" ) == " 0" );
297+ BOOST_CHECK (testArgs.GetArgs (" -foo" ).size () == 2
298+ && testArgs.GetArgs (" -foo" ).front () == " 0"
299+ && testArgs.GetArgs (" -foo" ).back () == " 1" );
300+
301+ // Command line overrides, but doesn't erase old setting
302+ BOOST_CHECK (testArgs.IsArgNegated (" -bar" ));
303+ BOOST_CHECK (testArgs.GetArg (" -bar" , " xxx" ) == " " );
304+ BOOST_CHECK (testArgs.GetArgs (" -bar" ).size () == 2
305+ && testArgs.GetArgs (" -bar" ).front () == " "
306+ && testArgs.GetArgs (" -bar" ).back () == " 0" );
271307}
272308
273309BOOST_AUTO_TEST_CASE (util_ReadConfigStream)
0 commit comments