- /* Very long name of long option */
- {
- const char opt_name[] =
- "kale-chips-waistcoat-yr-bicycle-rights-gochujang-"
- "woke-tumeric-flexitarian-biodiesel-chillwave-cliche-"
- "ethical-cardigan-listicle-pok-pok-sustainable-live-"
- "edge-jianbing-gochujang-butcher-disrupt-tattooed-"
- "tumeric-prism-photo-booth-vape-kogi-jean-shorts-"
- "blog-williamsburg-fingerstache-palo-santo-artisan-"
- "affogato-occupy-skateboard-adaptogen-neutra-celiac-"
- "put-a-bird-on-it-kombucha-everyday-carry-hot-chicken-"
- "craft-beer-subway-tile-tote-bag-disrupt-selvage-"
- "raclette-art-party-readymade-paleo-heirloom-trust-"
- "fund-small-batch-kinfolk-woke-cardigan-prism-"
- "chambray-la-croix-hashtag-unicorn-edison-bulb-tbh-"
- "cornhole-cliche-tattooed-green-juice-adaptogen-"
- "kitsch-lo-fi-vexillologist-migas-gentrify-"
- "viral-raw-denim";
- const argpar_opt_descr_t descrs[] = {
- { 0, '\0', opt_name, true },
- ARGPAR_OPT_DESCR_SENTINEL
- };
- char cmdline[1024];
-
- sprintf(cmdline, "--%s=23", opt_name);
- test_succeed(cmdline, cmdline, descrs, 1);
- }
+ /* Single non-option argument */
+ {
+ const argpar_opt_descr_t descrs[] = {ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("kilojoule", "kilojoule<0,0>", descrs, 1);
+ }
+
+ /* Two non-option arguments */
+ {
+ const argpar_opt_descr_t descrs[] = {ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("kilojoule mitaine", "kilojoule<0,0> mitaine<1,1>", descrs, 2);
+ }
+
+ /* Single non-option argument mixed with options */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, 'd', NULL, false},
+ {0, '\0', "squeeze", true},
+ ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("-d sprout yes --squeeze little bag -d",
+ "-d sprout<1,0> yes<2,1> --squeeze=little bag<5,2> -d", descrs, 7);
+ }
+
+ /* Valid `---opt` */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, '\0', "-fuel", true}, ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("---fuel=three", "---fuel=three", descrs, 1);
+ }
+
+ /* Long option containing `=` in argument (equal form) */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, '\0', "zebra", true}, ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("--zebra=three=yes", "--zebra=three=yes", descrs, 1);
+ }
+
+ /* Short option's argument starting with `-` (glued form) */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, 'z', NULL, true}, ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("-z-will", "-z -will", descrs, 1);
+ }
+
+ /* Short option's argument starting with `-` (space form) */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, 'z', NULL, true}, ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("-z -will", "-z -will", descrs, 2);
+ }
+
+ /* Long option's argument starting with `-` (space form) */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, '\0', "janine", true}, ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("--janine -sutto", "--janine=-sutto", descrs, 2);
+ }
+
+ /* Long option's argument starting with `-` (equal form) */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, '\0', "janine", true}, ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("--janine=-sutto", "--janine=-sutto", descrs, 1);
+ }
+
+ /* Long option's empty argument (equal form) */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, 'f', NULL, false},
+ {0, '\0', "yeah", true},
+ ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("-f --yeah= -f", "-f --yeah= -f", descrs, 3);
+ }
+
+ /* `-` non-option argument */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, 'f', NULL, false}, ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("-f - -f", "-f -<1,0> -f", descrs, 3);
+ }
+
+ /* `--` non-option argument */
+ {
+ const argpar_opt_descr_t descrs[] = {{0, 'f', NULL, false}, ARGPAR_OPT_DESCR_SENTINEL};
+
+ test_succeed("-f -- -f", "-f --<1,0> -f", descrs, 3);
+ }
+
+ /* Very long name of long option */
+ {
+ const char opt_name[] = "kale-chips-waistcoat-yr-bicycle-rights-gochujang-"
+ "woke-tumeric-flexitarian-biodiesel-chillwave-cliche-"
+ "ethical-cardigan-listicle-pok-pok-sustainable-live-"
+ "edge-jianbing-gochujang-butcher-disrupt-tattooed-"
+ "tumeric-prism-photo-booth-vape-kogi-jean-shorts-"
+ "blog-williamsburg-fingerstache-palo-santo-artisan-"
+ "affogato-occupy-skateboard-adaptogen-neutra-celiac-"
+ "put-a-bird-on-it-kombucha-everyday-carry-hot-chicken-"
+ "craft-beer-subway-tile-tote-bag-disrupt-selvage-"
+ "raclette-art-party-readymade-paleo-heirloom-trust-"
+ "fund-small-batch-kinfolk-woke-cardigan-prism-"
+ "chambray-la-croix-hashtag-unicorn-edison-bulb-tbh-"
+ "cornhole-cliche-tattooed-green-juice-adaptogen-"
+ "kitsch-lo-fi-vexillologist-migas-gentrify-"
+ "viral-raw-denim";
+ const argpar_opt_descr_t descrs[] = {{0, '\0', opt_name, true}, ARGPAR_OPT_DESCR_SENTINEL};
+ char cmdline[1024];
+
+ sprintf(cmdline, "--%s=23", opt_name);
+ test_succeed(cmdline, cmdline, descrs, 1);
+ }