@@ -257,72 +257,70 @@ BOOST_FIXTURE_TEST_CASE(util_CheckValue, CheckValueTest)
257257 CheckValue (ArgsManager::ALLOW_ANY, " -value=2" , Expect{}.String (" 2" ).Int (2 ).Bool (true ).Many ({" 2" }));
258258 CheckValue (ArgsManager::ALLOW_ANY, " -value=abc" , Expect{}.String (" abc" ).Int (0 ).Bool (false ).Many ({" abc" }));
259259
260- /* Type checks are mostly not implemented yet, so the tests below for different flags below expect mostly same behavior as ALLOW_ANY */
261-
262- CheckValue (ArgsManager::TYPE_BOOL, " -novalue" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
263- CheckValue (ArgsManager::TYPE_BOOL, " -novalue=" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
264- CheckValue (ArgsManager::TYPE_BOOL, " -novalue=0" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
265- CheckValue (ArgsManager::TYPE_BOOL, " -novalue=1" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
266- CheckValue (ArgsManager::TYPE_BOOL, " -novalue=2" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
267- CheckValue (ArgsManager::TYPE_BOOL, " -novalue=abc" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
268- CheckValue (ArgsManager::TYPE_BOOL, " -value" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
269- CheckValue (ArgsManager::TYPE_BOOL, " -value=" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
270- CheckValue (ArgsManager::TYPE_BOOL, " -value=0" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({" 0" }));
271- CheckValue (ArgsManager::TYPE_BOOL, " -value=1" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
272- CheckValue (ArgsManager::TYPE_BOOL, " -value=2" , Expect{}.String (" 2" ).Int (2 ).Bool (true ).Many ({" 2" }));
273- CheckValue (ArgsManager::TYPE_BOOL, " -value=abc" , Expect{}.String (" abc" ).Int (0 ).Bool (false ).Many ({" abc" }));
274-
275- CheckValue (ArgsManager::TYPE_INT, " -novalue" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
276- CheckValue (ArgsManager::TYPE_INT, " -novalue=" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
277- CheckValue (ArgsManager::TYPE_INT, " -novalue=0" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
278- CheckValue (ArgsManager::TYPE_INT, " -novalue=1" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
279- CheckValue (ArgsManager::TYPE_INT, " -novalue=2" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
280- CheckValue (ArgsManager::TYPE_INT, " -novalue=abc" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
281- CheckValue (ArgsManager::TYPE_INT, " -value" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
282- CheckValue (ArgsManager::TYPE_INT, " -value=" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
283- CheckValue (ArgsManager::TYPE_INT, " -value=0" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({" 0" }));
284- CheckValue (ArgsManager::TYPE_INT, " -value=1" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
285- CheckValue (ArgsManager::TYPE_INT, " -value=2" , Expect{}.String (" 2" ).Int (2 ).Bool (true ).Many ({" 2" }));
286- CheckValue (ArgsManager::TYPE_INT, " -value=abc" , Expect{}.String (" abc" ).Int (0 ).Bool (false ).Many ({" abc" }));
287-
288- CheckValue (ArgsManager::TYPE_STRING, " -novalue" , Expect{}.Error (" Negating of -value is meaningless and therefore forbidden" ));
289- CheckValue (ArgsManager::TYPE_STRING, " -novalue=" , Expect{}.Error (" Negating of -value is meaningless and therefore forbidden" ));
290- CheckValue (ArgsManager::TYPE_STRING, " -novalue=0" , Expect{}.Error (" Negating of -value is meaningless and therefore forbidden" ));
291- CheckValue (ArgsManager::TYPE_STRING, " -novalue=1" , Expect{}.Error (" Negating of -value is meaningless and therefore forbidden" ));
292- CheckValue (ArgsManager::TYPE_STRING, " -novalue=2" , Expect{}.Error (" Negating of -value is meaningless and therefore forbidden" ));
293- CheckValue (ArgsManager::TYPE_STRING, " -novalue=abc" , Expect{}.Error (" Negating of -value is meaningless and therefore forbidden" ));
294- CheckValue (ArgsManager::TYPE_STRING, " -value" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
295- CheckValue (ArgsManager::TYPE_STRING, " -value=" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
296- CheckValue (ArgsManager::TYPE_STRING, " -value=0" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({" 0" }));
297- CheckValue (ArgsManager::TYPE_STRING, " -value=1" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
298- CheckValue (ArgsManager::TYPE_STRING, " -value=2" , Expect{}.String (" 2" ).Int (2 ).Bool (true ).Many ({" 2" }));
299- CheckValue (ArgsManager::TYPE_STRING, " -value=abc" , Expect{}.String (" abc" ).Int (0 ).Bool (false ).Many ({" abc" }));
300-
301- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
302- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
303- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=0" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
304- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=1" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
305- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=2" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
306- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=abc" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
307- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
308- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
309- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=0" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({" 0" }));
310- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=1" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
311- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=2" , Expect{}.String (" 2" ).Int (2 ).Bool (true ).Many ({" 2" }));
312- CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=abc" , Expect{}.String (" abc" ).Int (0 ).Bool (false ).Many ({" abc" }));
313-
314- CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
315- CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
316- CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=0" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
317- CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=1" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
318- CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=2" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({}));
319- CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=abc" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
320- CheckValue (ArgsManager::TYPE_STRING_LIST, " -value" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
321- CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=" , Expect{}.String (" " ).Int (0 ).Bool (true ).Many ({" " }));
322- CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=0" , Expect{}.String (" 0" ).Int (0 ).Bool (false ).Many ({" 0" }));
323- CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=1" , Expect{}.String (" 1" ).Int (1 ).Bool (true ).Many ({" 1" }));
324- CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=2" , Expect{}.String (" 2" ).Int (2 ).Bool (true ).Many ({" 2" }));
325- CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=abc" , Expect{}.String (" abc" ).Int (0 ).Bool (false ).Many ({" abc" }));
260+ CheckValue (ArgsManager::TYPE_BOOL, " -novalue" , Expect{}.Bool (false ));
261+ CheckValue (ArgsManager::TYPE_BOOL, " -novalue=" , Expect{}.Error (" Can not negate -value at the same time as setting value ''" ));
262+ CheckValue (ArgsManager::TYPE_BOOL, " -novalue=0" , Expect{}.Error (" Can not negate -value at the same time as setting value '0'" ));
263+ CheckValue (ArgsManager::TYPE_BOOL, " -novalue=1" , Expect{}.Bool (false ));
264+ CheckValue (ArgsManager::TYPE_BOOL, " -novalue=2" , Expect{}.Error (" Can not negate -value at the same time as setting value '2'" ));
265+ CheckValue (ArgsManager::TYPE_BOOL, " -novalue=abc" , Expect{}.Error (" Can not negate -value at the same time as setting value 'abc'" ));
266+ CheckValue (ArgsManager::TYPE_BOOL, " -value" , Expect{}.Bool (true ));
267+ CheckValue (ArgsManager::TYPE_BOOL, " -value=" , Expect{}.Error (" It must be set to 0 or 1" ));
268+ CheckValue (ArgsManager::TYPE_BOOL, " -value=0" , Expect{}.Bool (false ));
269+ CheckValue (ArgsManager::TYPE_BOOL, " -value=1" , Expect{}.Bool (true ));
270+ CheckValue (ArgsManager::TYPE_BOOL, " -value=2" , Expect{}.Error (" It must be set to 0 or 1" ));
271+ CheckValue (ArgsManager::TYPE_BOOL, " -value=abc" , Expect{}.Error (" It must be set to 0 or 1" ));
272+
273+ CheckValue (ArgsManager::TYPE_INT, " -novalue" , Expect{}.Int (0 ).Bool (false ));
274+ CheckValue (ArgsManager::TYPE_INT, " -novalue=" , Expect{}.Error (" Can not negate -value at the same time as setting value ''" ));
275+ CheckValue (ArgsManager::TYPE_INT, " -novalue=0" , Expect{}.Error (" Can not negate -value at the same time as setting value '0'" ));
276+ CheckValue (ArgsManager::TYPE_INT, " -novalue=1" , Expect{}.Int (0 ).Bool (false ));
277+ CheckValue (ArgsManager::TYPE_INT, " -novalue=2" , Expect{}.Error (" Can not negate -value at the same time as setting value '2'" ));
278+ CheckValue (ArgsManager::TYPE_INT, " -novalue=abc" , Expect{}.Error (" Can not negate -value at the same time as setting value 'abc'" ));
279+ CheckValue (ArgsManager::TYPE_INT, " -value" , Expect{}.Error (" It must be set to an integer" ));
280+ CheckValue (ArgsManager::TYPE_INT, " -value=" , Expect{}.Error (" It must be set to an integer" ));
281+ CheckValue (ArgsManager::TYPE_INT, " -value=0" , Expect{}.Int (0 ).Bool (false ));
282+ CheckValue (ArgsManager::TYPE_INT, " -value=1" , Expect{}.Int (1 ).Bool (true ));
283+ CheckValue (ArgsManager::TYPE_INT, " -value=2" , Expect{}.Int (2 ).Bool (true ));
284+ CheckValue (ArgsManager::TYPE_INT, " -value=abc" , Expect{}.Error (" It must be set to an integer" ));
285+
286+ CheckValue (ArgsManager::TYPE_STRING, " -novalue" , Expect{}.Error (" Can not negate -value, it is required to have a value" ));
287+ CheckValue (ArgsManager::TYPE_STRING, " -novalue=" , Expect{}.Error (" Can not negate -value, it is required to have a value" ));
288+ CheckValue (ArgsManager::TYPE_STRING, " -novalue=0" , Expect{}.Error (" Can not negate -value, it is required to have a value" ));
289+ CheckValue (ArgsManager::TYPE_STRING, " -novalue=1" , Expect{}.Error (" Can not negate -value, it is required to have a value" ));
290+ CheckValue (ArgsManager::TYPE_STRING, " -novalue=2" , Expect{}.Error (" Can not negate -value, it is required to have a value" ));
291+ CheckValue (ArgsManager::TYPE_STRING, " -novalue=abc" , Expect{}.Error (" Can not negate -value, it is required to have a value" ));
292+ CheckValue (ArgsManager::TYPE_STRING, " -value" , Expect{}.Error (" It must be set to a string" ));
293+ CheckValue (ArgsManager::TYPE_STRING, " -value=" , Expect{}.String (" " ));
294+ CheckValue (ArgsManager::TYPE_STRING, " -value=0" , Expect{}.String (" 0" ));
295+ CheckValue (ArgsManager::TYPE_STRING, " -value=1" , Expect{}.String (" 1" ));
296+ CheckValue (ArgsManager::TYPE_STRING, " -value=2" , Expect{}.String (" 2" ));
297+ CheckValue (ArgsManager::TYPE_STRING, " -value=abc" , Expect{}.String (" abc" ));
298+
299+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue" , Expect{}.String (" " ).Bool (false ));
300+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=" , Expect{}.Error (" Can not negate -value at the same time as setting value ''" ));
301+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=0" , Expect{}.Error (" Can not negate -value at the same time as setting value '0'" ));
302+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=1" , Expect{}.String (" " ).Bool (false ));
303+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=2" , Expect{}.Error (" Can not negate -value at the same time as setting value '2'" ));
304+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -novalue=abc" , Expect{}.Error (" Can not negate -value at the same time as setting value 'abc'" ));
305+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value" , Expect{}.Error (" It must be set to a string" ));
306+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=" , Expect{}.String (" " ).Bool (true ));
307+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=0" , Expect{}.String (" 0" ).Bool (true ));
308+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=1" , Expect{}.String (" 1" ).Bool (true ));
309+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=2" , Expect{}.String (" 2" ).Bool (true ));
310+ CheckValue (ArgsManager::TYPE_OPTIONAL_STRING, " -value=abc" , Expect{}.String (" abc" ).Bool (true ));
311+
312+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue" , Expect{}.Many ({}));
313+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=" , Expect{}.Error (" Can not negate -value at the same time as setting value ''" ));
314+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=0" , Expect{}.Error (" Can not negate -value at the same time as setting value '0'" ));
315+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=1" , Expect{}.Many ({}));
316+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=2" , Expect{}.Error (" Can not negate -value at the same time as setting value '2'" ));
317+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -novalue=abc" , Expect{}.Error (" Can not negate -value at the same time as setting value 'abc'" ));
318+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -value" , Expect{}.Error (" It must be set to a string" ));
319+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=" , Expect{}.Many ({" " }));
320+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=0" , Expect{}.Many ({" 0" }));
321+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=1" , Expect{}.Many ({" 1" }));
322+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=2" , Expect{}.Many ({" 2" }));
323+ CheckValue (ArgsManager::TYPE_STRING_LIST, " -value=abc" , Expect{}.Many ({" abc" }));
326324}
327325
328326BOOST_AUTO_TEST_CASE (CheckSingleValue)
@@ -331,8 +329,8 @@ BOOST_AUTO_TEST_CASE(CheckSingleValue)
331329 test.SetupArgs ({{" -single" , ArgsManager::TYPE_INT}});
332330 std::istringstream stream (" single=1\n single=2\n " );
333331 std::string error;
334- BOOST_CHECK (test.ReadConfigStream (stream, " file.conf" , error));
335- BOOST_CHECK_EQUAL (error, " " );
332+ BOOST_CHECK (! test.ReadConfigStream (stream, " file.conf" , error));
333+ BOOST_CHECK_EQUAL (error, " Multiple values specified for -single in same section of config file. " );
336334}
337335
338336BOOST_AUTO_TEST_CASE (util_ParseParameters)
0 commit comments