50 #define COPANOERR(COP) \
52 std::ostringstream oss; \
53 oss << "CommandOptionParser has errors:" << endl; \
54 COP.dumpErrors(oss); \
55 testFramework.assert(!COP.hasErrors(), oss.str(), __LINE__); \
64 int testInitialization();
66 int testParseOptions();
67 int testOptionPresence();
78 TUDEF(
"CommandOptionParser",
"Initialization");
84 TUPASS(
"CommandOptionParser was created successfully.");
88 TUFAIL(
"CommandOptionParser() threw an exception but should not have.");
95 TUPASS(
"CommandOptionParser was created successfully.");
99 TUFAIL(
"CommandOptionParser() threw an exception but should not have.");
107 TUPASS(
"CommandOptionParser was created successfully.");
111 TUFAIL(
"CommandOptionParser() threw an exception but should not have.");
118 CommandOption::stdType,
'f',
"foo",
"Foo",
false,
121 CommandOption::stdType,
'b',
"bar",
"Boo",
false,
125 TUPASS(
"CommandOptions were added successfully.");
129 TUFAIL(
"CommandOptionParser() threw an exception but should not have.");
135 CommandOption cmdOpt1(CommandOption::noArgument, CommandOption::stdType,
136 'f',
"foo",
"Foo",
false, testCmdOptVec);
137 CommandOption cmdOpt2(CommandOption::noArgument, CommandOption::stdType,
138 'f',
"far",
"Far",
false, testCmdOptVec);
140 TUFAIL(
"CommandOptionParser should have disallowed conflicting short"
145 TUPASS(
"CommandOptionParser correctly threw an exception to disallow"
146 " conflicting short options.");
152 CommandOption cmdOpt1(CommandOption::noArgument, CommandOption::stdType,
153 'f',
"foo",
"Foo1",
false, testCmdOptVec);
154 CommandOption cmdOpt2(CommandOption::noArgument, CommandOption::stdType,
155 'F',
"foo",
"Foo2",
false, testCmdOptVec);
157 TUFAIL(
"CommandOptionParser should have disallowed conflicting long"
162 TUPASS(
"CommandOptionParser correctly threw an exception to disallow"
163 " conflicting long options.");
170 CommandOption::trailingType, 0,
"",
"Foo1",
false,
173 CommandOption::trailingType, 0,
"",
"Foo2",
false,
176 TUFAIL(
"CommandOptionParser should have disallowed multiple"
177 " CommandOptionRest instances.");
181 TUPASS(
"CommandOptionParser correctly threw an exception to multiple"
182 " CommandOptionRest instances.");
193 TUDEF(
"CommandOptionParser",
"AddOption");
198 CommandOption cmdOpt1(CommandOption::noArgument, CommandOption::stdType,
199 'f',
"foo",
"Foo",
false, testCmdOptVec);
200 CommandOption cmdOpt2(CommandOption::noArgument, CommandOption::stdType,
201 'b',
"bar",
"Boo",
false, testCmdOptVec);
205 TUPASS(
"CommandOptions were added successfully.");
209 TUFAIL(
"CommandOptionParser() threw an exception but should not have.");
215 CommandOption cmdOpt1(CommandOption::noArgument, CommandOption::stdType,
216 'f',
"foo",
"Foo",
false, testCmdOptVec);
217 CommandOption cmdOpt2(CommandOption::noArgument, CommandOption::stdType,
218 'f',
"far",
"Far",
false, testCmdOptVec);
222 TUFAIL(
"CommandOptionParser should have disallowed conflicting short"
227 TUPASS(
"CommandOptionParser correctly threw an exception to disallow"
228 " conflicting short options.");
234 CommandOption cmdOpt1(CommandOption::noArgument, CommandOption::stdType,
235 'f',
"foo",
"Foo1",
false, testCmdOptVec);
236 CommandOption cmdOpt2(CommandOption::noArgument, CommandOption::stdType,
237 'F',
"foo",
"Foo2",
false, testCmdOptVec);
241 TUFAIL(
"CommandOptionParser should have disallowed conflicting long"
246 TUPASS(
"CommandOptionParser correctly threw an exception to disallow"
247 " conflicting long options.");
254 CommandOption::trailingType, 0,
"",
"Foo1",
false,
257 CommandOption::trailingType, 0,
"",
"Foo2",
false,
262 TUFAIL(
"CommandOptionParser should have disallowed multiple"
263 " CommandOptionRest instances.");
267 TUPASS(
"CommandOptionParser correctly threw an exception to multiple"
268 " CommandOptionRest instances.");
279 TUDEF(
"CommandOptionParser",
"ParseOptions");
285 char* argv[] = {
const_cast<char*
>(
"program") };
287 TUPASS(
"CommandOptionParser parsed the options without throwing an"
291 std::ostringstream oss;
292 oss <<
"CommandOptionParser encountered unexpected errors while"
299 TUPASS(
"CommandOptionParser parsed without errors.");
304 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
305 " should not have.");
311 CommandOption cmdOpt(CommandOption::noArgument, CommandOption::stdType,
312 'f',
"foo",
"Foo",
false, testCmdOptVec);
315 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-f")};
317 TUPASS(
"CommandOptionParser parsed the options without throwing an"
321 std::ostringstream oss;
322 oss <<
"CommandOptionParser encountered unexpected errors while"
329 TUPASS(
"CommandOptionParser parsed without errors.");
330 std::ostringstream countOss;
333 std::ostringstream orderOss;
340 TUFAIL(
"CommandOptionParser() threw an unexpected exception.");
346 CommandOption cmdOpt(CommandOption::hasArgument, CommandOption::stdType,
347 'f',
"foo",
"Foo",
false, testCmdOptVec);
350 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-f"),
351 const_cast<char*
>(
"value") };
353 TUPASS(
"CommandOptionParser parsed the options without throwing an"
357 std::ostringstream oss;
358 oss <<
"CommandOptionParser encountered unexpected errors while"
365 TUPASS(
"CommandOptionParser parsed without errors.");
366 std::ostringstream countOss;
369 std::ostringstream orderOss;
372 std::vector<std::string> values = cmdOpt.
getValue();
373 TUASSERTE(
unsigned long,1,values.size());
374 if (values.size() == 1)
376 TUASSERTE(
unsigned long,0,values[0].compare(
"value"));
382 TUFAIL(
"CommandOptionParser() threw an unexpected exception.");
388 CommandOption cmdOpt(CommandOption::noArgument, CommandOption::stdType,
389 'f',
"foo",
"Foo",
false, testCmdOptVec);
392 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-g")};
394 TUPASS(
"CommandOptionParser parsed the options without throwing an"
400 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
401 " should not have.");
407 CommandOption cmdOpt(CommandOption::noArgument, CommandOption::stdType,
408 'f',
"foo",
"Foo",
false, testCmdOptVec);
411 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-f"),
412 const_cast<char*
>(
"trailing") };
414 TUPASS(
"CommandOptionParser parsed the options without throwing an"
420 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
421 " should not have.");
427 CommandOption cmdOpt(CommandOption::noArgument, CommandOption::stdType,
428 'f',
"foo",
"Foo",
true, testCmdOptVec);
431 char* argv[] = {
const_cast<char*
>(
"program"),
432 const_cast<char*
>(
"trailing") };
434 TUPASS(
"CommandOptionParser parsed the options without throwing an"
440 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
441 " should not have.");
447 CommandOption cmdOpt(CommandOption::noArgument, CommandOption::stdType,
448 'f',
"foo",
"Foo",
false, testCmdOptVec);
452 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-f"),
453 const_cast<char*
>(
"-f") };
455 TUPASS(
"CommandOptionParser parsed the options without throwing an"
461 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
462 " should not have.");
468 CommandOption cmdOpt1(CommandOption::noArgument, CommandOption::stdType,
469 'f',
"foo",
"Foo",
false, testCmdOptVec);
470 CommandOption cmdOpt2(CommandOption::noArgument, CommandOption::stdType,
471 'g',
"goo",
"Goo",
false, testCmdOptVec);
474 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-g"),
475 const_cast<char*
>(
"-f") };
477 TUPASS(
"CommandOptionParser parsed the options without throwing an"
481 std::ostringstream oss;
482 oss <<
"CommandOptionParser encountered unexpected errors while"
489 TUPASS(
"CommandOptionParser parsed without errors.");
490 std::ostringstream count1Oss;
493 std::ostringstream count2Oss;
496 std::ostringstream order1Oss;
499 std::ostringstream order2Oss;
506 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
507 " should not have.");
513 CommandOption cmdOpt(CommandOption::noArgument, CommandOption::stdType,
514 0,
"foo",
"Foo",
false, testCmdOptVec);
517 char* argv[] = {
const_cast<char*
>(
"program"),
518 const_cast<char*
>(
"--foo") };
520 TUPASS(
"CommandOptionParser parsed the options without throwing an"
524 std::ostringstream oss;
525 oss <<
"CommandOptionParser encountered unexpected errors while"
532 TUPASS(
"CommandOptionParser parsed without errors.");
533 std::ostringstream countOss;
536 std::ostringstream orderOss;
543 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
544 " should not have.");
550 CommandOption cmdOpt(CommandOption::noArgument, CommandOption::stdType,
551 'f',
"",
"Foo",
false, testCmdOptVec);
554 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-f")};
556 TUPASS(
"CommandOptionParser parsed the options without throwing an"
560 std::ostringstream oss;
561 oss <<
"CommandOptionParser encountered unexpected errors while"
568 TUPASS(
"CommandOptionParser parsed without errors.");
569 std::ostringstream countOss;
572 std::ostringstream orderOss;
579 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
580 " should not have.");
590 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-f"),
591 const_cast<char*
>(
"--foo") };
593 TUPASS(
"CommandOptionParser parsed the options without throwing an"
597 std::ostringstream oss;
598 oss <<
"CommandOptionParser encountered unexpected errors while"
605 TUPASS(
"CommandOptionParser parsed without errors.");
606 std::ostringstream countOss;
609 std::ostringstream orderOss;
616 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
617 " should not have.");
628 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-f"),
629 const_cast<char*
>(
"value1"),
630 const_cast<char*
>(
"--foo"),
631 const_cast<char*
>(
"value2") };
633 TUPASS(
"CommandOptionParser parsed the options without throwing an"
637 std::ostringstream oss;
638 oss <<
"CommandOptionParser encountered unexpected errors while"
645 TUPASS(
"CommandOptionParser parsed without errors.");
646 std::ostringstream countOss;
649 std::ostringstream orderOss;
652 std::vector<std::string> values = cmdOpt.
getValue();
653 TUASSERTE(
unsigned long,2,values.size());
654 if (values.size() == 2)
656 TUASSERTE(std::string,
"value1",values[0]);
657 TUASSERTE(std::string,
"value2",values[1]);
663 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
664 " should not have.");
674 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-f"),
675 const_cast<char*
>(
"value1"),
676 const_cast<char*
>(
"--foo"),
677 const_cast<char*
>(
"value2") };
679 TUPASS(
"CommandOptionParser parsed the options without throwing an"
683 std::ostringstream oss;
684 oss <<
"CommandOptionParser encountered unexpected errors while"
691 TUPASS(
"CommandOptionParser parsed without errors.");
692 std::ostringstream countOss;
695 std::ostringstream orderOss;
698 std::vector<std::string> values = cmdOpt.
getValue();
699 TUASSERTE(
unsigned long,2,values.size());
700 if (values.size() == 2)
702 TUASSERTE(std::string,
"value1",values[0]);
703 TUASSERTE(std::string,
"value2",values[1]);
709 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
710 " should not have.");
720 char* argv[] = {
const_cast<char*
>(
"program"),
721 const_cast<char*
>(
"-f"),
722 const_cast<char*
>(
"value1"),
723 const_cast<char*
>(
"--foo"),
724 const_cast<char*
>(
"value2") };
726 TUPASS(
"CommandOptionParser parsed the options without throwing an"
730 std::ostringstream oss;
731 oss <<
"CommandOptionParser encountered expected errors while"
738 TUFAIL(
"CommandOptionParser parsed without errors but should have"
739 " rejected the argument value due to its format");
744 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
745 " should not have.");
755 char* argv[] = {
const_cast<char*
>(
"program"),
const_cast<char*
>(
"-f"),
756 const_cast<char*
>(
"valueOne"),
757 const_cast<char*
>(
"--foo"),
758 const_cast<char*
>(
"valueTwo") };
760 TUPASS(
"CommandOptionParser parsed the options without throwing an"
764 std::ostringstream oss;
765 oss <<
"CommandOptionParser encountered unexpected errors while"
772 TUPASS(
"CommandOptionParser parsed without errors.");
773 std::ostringstream countOss;
776 std::ostringstream orderOss;
779 std::vector<std::string> values = cmdOpt.
getValue();
780 TUASSERTE(
unsigned long,2,values.size());
781 if (values.size() == 2)
783 TUASSERTE(std::string,
"valueOne",values[0]);
784 TUASSERTE(std::string,
"valueTwo",values[1]);
790 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
791 " should not have.");
801 char* argv[] = {
const_cast<char*
>(
"program"),
802 const_cast<char*
>(
"-f"),
803 const_cast<char*
>(
"value"),
804 const_cast<char*
>(
"--foo"),
805 const_cast<char*
>(
"12.45") };
807 TUPASS(
"CommandOptionParser parsed the options without throwing an"
811 std::ostringstream oss;
812 oss <<
"CommandOptionParser encountered expected errors while"
819 TUFAIL(
"CommandOptionParser parsed without errors but should have"
820 " rejected the argument value due to its format");
825 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
826 " should not have.");
836 char* argv[] = {
const_cast<char*
>(
"program"),
837 const_cast<char*
>(
"-f"),
838 const_cast<char*
>(
"0"),
839 const_cast<char*
>(
"--foo"),
840 const_cast<char*
>(
"12345") };
842 TUPASS(
"CommandOptionParser parsed the options without throwing an"
846 std::ostringstream oss;
847 oss <<
"CommandOptionParser encountered unexpected errors while"
854 TUPASS(
"CommandOptionParser parsed without errors.");
855 std::ostringstream countOss;
858 std::ostringstream orderOss;
861 std::vector<std::string> values = cmdOpt.
getValue();
862 TUASSERTE(
unsigned long,2,values.size());
863 if (values.size() == 2)
866 TUASSERTE(std::string,
"12345",values[1]);
872 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
873 " should not have.");
883 char* argv[] = {
const_cast<char*
>(
"program"),
884 const_cast<char*
>(
"-f"),
885 const_cast<char*
>(
"value"),
886 const_cast<char*
>(
"--foo"),
887 const_cast<char*
>(
"1.2e34") };
889 TUPASS(
"CommandOptionParser parsed the options without throwing an"
893 std::ostringstream oss;
894 oss <<
"CommandOptionParser encountered expected errors while"
901 TUFAIL(
"CommandOptionParser parsed without errors but should have"
902 " rejected the argument value due to its format");
907 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
908 " should not have.");
918 char* argv[] = {
const_cast<char*
>(
"program"),
919 const_cast<char*
>(
"-f"),
920 const_cast<char*
>(
"0"),
921 const_cast<char*
>(
"--foo"),
922 const_cast<char*
>(
"123.45") };
924 TUPASS(
"CommandOptionParser parsed the options without throwing an"
928 std::ostringstream oss;
929 oss <<
"CommandOptionParser encountered unexpected errors while"
936 TUPASS(
"CommandOptionParser parsed without errors.");
937 std::ostringstream countOss;
940 std::ostringstream orderOss;
943 std::vector<std::string> values = cmdOpt.
getValue();
944 TUASSERTE(
unsigned long,2,values.size());
945 if (values.size() == 2)
948 TUASSERTE(std::string,
"123.45",values[1]);
954 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
955 " should not have.");
966 char* argv[] = {
const_cast<char*
>(
"program"),
967 const_cast<char*
>(
"-t"),
968 const_cast<char*
>(
"value"),
969 const_cast<char*
>(
"--time"),
970 const_cast<char*
>(
"1234") };
972 TUPASS(
"CommandOptionParser parsed the options without throwing an"
976 std::ostringstream oss;
977 oss <<
"CommandOptionParser encountered expected errors while"
984 TUFAIL(
"CommandOptionParser parsed without errors but should have"
985 " rejected the argument value due to its format.");
990 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
991 " should not have.");
1002 char* argv[] = {
const_cast<char*
>(
"program"),
1003 const_cast<char*
>(
"-t"),
1004 const_cast<char*
>(
"2015 123 45678.0"),
1005 const_cast<char*
>(
"--time"),
1006 const_cast<char*
>(
"2015 234 56789.0") };
1008 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1012 std::ostringstream oss;
1013 oss <<
"CommandOptionParser encountered unexpected errors while"
1020 TUPASS(
"CommandOptionParser parsed without errors.");
1021 std::ostringstream countOss;
1024 std::ostringstream orderOss;
1027 std::vector<std::string> values = cmdOpt.
getValue();
1028 TUASSERTE(
unsigned long,2,values.size());
1029 if (values.size() == 2)
1031 TUASSERTE(std::string,
"2015 123 45678.0",values[0]);
1032 TUASSERTE(std::string,
"2015 234 56789.0",values[1]);
1034 std::vector<gnsstk::CommonTime> times = cmdOpt.
getTime();
1035 TUASSERTE(
unsigned long,2,times.size());
1036 if (times.size() == 2)
1049 TUFAIL(
"CommandOptionParser() threw an unexpected exception.");
1059 char* argv[] = {
const_cast<char*
>(
"program") };
1061 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1067 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1068 " should not have.");
1078 char* argv[] = {
const_cast<char*
>(
"program"),
1079 const_cast<char*
>(
"trailing1"),
1080 const_cast<char*
>(
"trailing2") };
1082 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1086 std::ostringstream oss;
1087 oss <<
"CommandOptionParser encountered unexpected errors while"
1094 TUPASS(
"CommandOptionParser parsed without errors.");
1095 std::ostringstream countOss;
1098 std::ostringstream orderOss;
1101 std::vector<std::string> values = cmdOpt.
getValue();
1102 TUASSERTE(
unsigned long,2,values.size());
1103 if (values.size() == 2)
1105 TUASSERTE(std::string,
"trailing1",values[0]);
1106 TUASSERTE(std::string,
"trailing2",values[1]);
1112 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1113 " should not have.");
1126 TUDEF(
"CommandOptionParser",
"OptionPresence");
1138 char* argv[] = {
const_cast<char*
>(
"program"),
1139 const_cast<char*
>(
"-F"),
1140 const_cast<char*
>(
"value1"),
1141 const_cast<char*
>(
"--foo"),
1142 const_cast<char*
>(
"value2"),
1143 const_cast<char*
>(
"trailing") };
1145 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1149 std::ostringstream oss;
1150 oss <<
"CommandOptionParser encountered unexpected errors while"
1157 TUPASS(
"CommandOptionParser parsed without errors.");
1163 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1164 " should not have.");
1179 char* argv[] = {
const_cast<char*
>(
"program"),
1180 const_cast<char*
>(
"-F"),
1181 const_cast<char*
>(
"value1"),
1182 const_cast<char*
>(
"-B"),
1183 const_cast<char*
>(
"value2"),
1184 const_cast<char*
>(
"trailing") };
1186 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1192 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1193 " should not have.");
1208 char* argv[] = {
const_cast<char*
>(
"program"),
1209 const_cast<char*
>(
"-F"),
1210 const_cast<char*
>(
"value1"),
1211 const_cast<char*
>(
"-B"),
1212 const_cast<char*
>(
"value2"),
1213 const_cast<char*
>(
"trailing") };
1215 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1221 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1222 " should not have.");
1235 char* argv[] = {
const_cast<char*
>(
"program"),
1236 const_cast<char*
>(
"-F"),
1237 const_cast<char*
>(
"value1"),
1238 const_cast<char*
>(
"-B"),
1239 const_cast<char*
>(
"value2"),
1240 const_cast<char*
>(
"trailing") };
1242 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1246 std::ostringstream oss;
1247 oss <<
"CommandOptionParser encountered unexpected errors while"
1254 TUPASS(
"CommandOptionParser parsed without errors.");
1259 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1260 " should not have.");
1273 char* argv[] = {
const_cast<char*
>(
"program"),
1274 const_cast<char*
>(
"-F"),
1275 const_cast<char*
>(
"value1"),
1276 const_cast<char*
>(
"-B"),
1277 const_cast<char*
>(
"value2"),
1278 const_cast<char*
>(
"trailing") };
1280 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1284 std::ostringstream oss;
1285 oss <<
"CommandOptionParser encountered unexpected errors while"
1292 TUPASS(
"CommandOptionParser parsed without errors.");
1297 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1298 " should not have.");
1311 char* argv[] = {
const_cast<char*
>(
"program"),
1312 const_cast<char*
>(
"-F"),
1313 const_cast<char*
>(
"value1"),
1314 const_cast<char*
>(
"--foo"),
1315 const_cast<char*
>(
"value2"),
1316 const_cast<char*
>(
"trailing") };
1318 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1324 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1325 " should not have.");
1338 char* argv[] = {
const_cast<char*
>(
"program"),
1339 const_cast<char*
>(
"-F"),
1340 const_cast<char*
>(
"value1"),
1341 const_cast<char*
>(
"--foo"),
1342 const_cast<char*
>(
"value2"),
1343 const_cast<char*
>(
"trailing") };
1345 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1351 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1352 " should not have.");
1366 char* argv[] = {
const_cast<char*
>(
"program"),
1367 const_cast<char*
>(
"-F"),
1368 const_cast<char*
>(
"value1"),
1369 const_cast<char*
>(
"--foo"),
1370 const_cast<char*
>(
"value2"),
1371 const_cast<char*
>(
"trailing") };
1373 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1377 std::ostringstream oss;
1378 oss <<
"CommandOptionParser encountered unexpected errors while"
1385 TUPASS(
"CommandOptionParser parsed without errors.");
1391 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1392 " should not have.");
1407 char* argv[] = {
const_cast<char*
>(
"program"),
1408 const_cast<char*
>(
"-F"),
1409 const_cast<char*
>(
"value1"),
1410 const_cast<char*
>(
"trailing") };
1412 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1416 std::ostringstream oss;
1417 oss <<
"CommandOptionParser encountered unexpected errors while"
1424 TUPASS(
"CommandOptionParser parsed without errors.");
1430 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1431 " should not have.");
1446 char* argv[] = {
const_cast<char*
>(
"program"),
1447 const_cast<char*
>(
"-F"),
1448 const_cast<char*
>(
"value1"),
1449 const_cast<char*
>(
"-B"),
1450 const_cast<char*
>(
"value2"),
1451 const_cast<char*
>(
"trailing") };
1453 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1457 std::ostringstream oss;
1458 oss <<
"CommandOptionParser encountered unexpected errors while"
1465 TUPASS(
"CommandOptionParser parsed without errors.");
1471 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1472 " should not have.");
1487 char* argv[] = {
const_cast<char*
>(
"program"),
1488 const_cast<char*
>(
"-F"),
1489 const_cast<char*
>(
"value1"),
1490 const_cast<char*
>(
"--foo"),
1491 const_cast<char*
>(
"value2"),
1492 const_cast<char*
>(
"trailing") };
1494 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1498 std::ostringstream oss;
1499 oss <<
"CommandOptionParser encountered unexpected errors while"
1506 TUPASS(
"CommandOptionParser parsed without errors.");
1512 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1513 " should not have.");
1527 char* argv[] = {
const_cast<char*
>(
"program"),
1528 const_cast<char*
>(
"-F"),
1529 const_cast<char*
>(
"value1"),
1530 const_cast<char*
>(
"-B"),
1531 const_cast<char*
>(
"value2"),
1532 const_cast<char*
>(
"trailing") };
1534 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1540 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1541 " should not have.");
1556 char* argv[] = {
const_cast<char*
>(
"program"),
1557 const_cast<char*
>(
"-F"),
1558 const_cast<char*
>(
"value1"),
1559 const_cast<char*
>(
"-B"),
1560 const_cast<char*
>(
"value2"),
1561 const_cast<char*
>(
"trailing") };
1563 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1569 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1570 " should not have.");
1585 char* argv[] = {
const_cast<char*
>(
"program"),
1586 const_cast<char*
>(
"-F"),
1587 const_cast<char*
>(
"value1"),
1588 const_cast<char*
>(
"-B"),
1589 const_cast<char*
>(
"value2"),
1590 const_cast<char*
>(
"trailing") };
1592 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1598 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1599 " should not have.");
1613 char* argv[] = {
const_cast<char*
>(
"program"),
1614 const_cast<char*
>(
"-F"),
1615 const_cast<char*
>(
"value1"),
1616 const_cast<char*
>(
"-B"),
1617 const_cast<char*
>(
"value2"),
1618 const_cast<char*
>(
"trailing") };
1620 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1624 std::ostringstream oss;
1625 oss <<
"CommandOptionParser encountered unexpected errors while"
1632 TUPASS(
"CommandOptionParser parsed without errors.");
1638 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1639 " should not have.");
1654 char* argv[] = {
const_cast<char*
>(
"program"),
1655 const_cast<char*
>(
"-F"),
1656 const_cast<char*
>(
"value1"),
1657 const_cast<char*
>(
"--foo"),
1658 const_cast<char*
>(
"value2"),
1659 const_cast<char*
>(
"trailing") };
1661 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1665 std::ostringstream oss;
1666 oss <<
"CommandOptionParser encountered unexpected errors while"
1673 TUPASS(
"CommandOptionParser parsed without errors.");
1679 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1680 " should not have.");
1695 char* argv[] = {
const_cast<char*
>(
"program"),
1696 const_cast<char*
>(
"-F"),
1697 const_cast<char*
>(
"value1"),
1698 const_cast<char*
>(
"--foo"),
1699 const_cast<char*
>(
"value2") };
1701 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1707 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1708 " should not have.");
1722 char* argv[] = {
const_cast<char*
>(
"program"),
1723 const_cast<char*
>(
"-F"),
1724 const_cast<char*
>(
"value1"),
1725 const_cast<char*
>(
"-B"),
1726 const_cast<char*
>(
"value2"),
1727 const_cast<char*
>(
"trailing") };
1729 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1733 std::ostringstream oss;
1734 oss <<
"CommandOptionParser encountered unexpected errors while"
1741 TUPASS(
"CommandOptionParser parsed without errors.");
1746 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1747 " should not have.");
1763 char* argv[] = {
const_cast<char*
>(
"program"),
1764 const_cast<char*
>(
"-F"),
1765 const_cast<char*
>(
"value1"),
1766 const_cast<char*
>(
"-B"),
1767 const_cast<char*
>(
"value2"),
1768 const_cast<char*
>(
"trailing") };
1770 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1774 std::ostringstream oss;
1775 oss <<
"CommandOptionParser encountered unexpected errors while"
1782 TUPASS(
"CommandOptionParser parsed without errors.");
1787 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1788 " should not have.");
1804 char* argv[] = {
const_cast<char*
>(
"program"),
1805 const_cast<char*
>(
"-F"),
1806 const_cast<char*
>(
"value1"),
1807 const_cast<char*
>(
"--foo"),
1808 const_cast<char*
>(
"value2"),
1809 const_cast<char*
>(
"trailing") };
1811 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1817 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1818 " should not have.");
1843 char* argv[] = {
const_cast<char*
>(
"program"),
1844 const_cast<char*
>(
"-F"),
1845 const_cast<char*
>(
"value1"),
1846 const_cast<char*
>(
"--foo"),
1847 const_cast<char*
>(
"value2"),
1848 const_cast<char*
>(
"trailing") };
1850 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1854 std::ostringstream oss;
1855 oss <<
"CommandOptionParser encountered unexpected errors while"
1862 TUPASS(
"CommandOptionParser parsed without errors.");
1868 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1869 " should not have.");
1886 char* argv[] = {
const_cast<char*
>(
"program"),
1887 const_cast<char*
>(
"-J"),
1888 const_cast<char*
>(
"value1"),
1889 const_cast<char*
>(
"trailing") };
1891 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1897 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1898 " should not have.");
1914 char* argv[] = {
const_cast<char*
>(
"program"),
1915 const_cast<char*
>(
"-F"),
1916 const_cast<char*
>(
"value1"),
1917 const_cast<char*
>(
"-B"),
1918 const_cast<char*
>(
"value2"),
1919 const_cast<char*
>(
"trailing") };
1921 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1925 std::ostringstream oss;
1926 oss <<
"CommandOptionParser encountered unexpected errors while"
1933 TUPASS(
"CommandOptionParser parsed without errors.");
1939 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1940 " should not have.");
1956 char* argv[] = {
const_cast<char*
>(
"program"),
1957 const_cast<char*
>(
"-F"),
1958 const_cast<char*
>(
"value1"),
1959 const_cast<char*
>(
"--foo"),
1960 const_cast<char*
>(
"value2"),
1961 const_cast<char*
>(
"trailing") };
1963 TUPASS(
"CommandOptionParser parsed the options without throwing an"
1969 TUFAIL(
"CommandOptionParser() threw an exception while parsing but"
1970 " should not have.");
1981 unsigned argc,
char *argv[])
1994 TUPASS(
"Constructed objects");
2001 std::vector<CommandOption*> witches = nof.
which();
2002 TUASSERTE(
unsigned, expWhich, witches.size());
2011 TUFAIL(
"Unexpected exception");
2018 TUDEF(
"CommandOptionNOf",
"which");
2023 const_cast<char*
>(
"program1"),
2024 const_cast<char*
>(
"-f"),
2025 const_cast<char*
>(
"wub1"),
2026 const_cast<char*
>(
"-b"),
2027 const_cast<char*
>(
"wub2"),
2028 const_cast<char*
>(
"-B"),
2029 const_cast<char*
>(
"wub3")
2035 const_cast<char*
>(
"program2"),
2036 const_cast<char*
>(
"-f"),
2037 const_cast<char*
>(
"wub1"),
2038 const_cast<char*
>(
"-f"),
2039 const_cast<char*
>(
"wub2")
2042 for (
unsigned argc = 1; argc <= 7; argc++)
2067 std::cout <<
"Total Failures for " << __FILE__ <<
": " << errorTotal
2070 return( errorTotal );