diff options
| author | Lion Kortlepel <[email protected]> | 2026-02-01 09:45:06 +0000 |
|---|---|---|
| committer | Lion Kortlepel <[email protected]> | 2026-02-01 09:45:06 +0000 |
| commit | acf522e7bab50b24ec702b405b4e450b65f835cd (patch) | |
| tree | 5109c3a0c25d054093d95984bb99c92d6da46510 /tests | |
| parent | b4feabc2c1dccb7212421c8e1edf57db6388a7a3 (diff) | |
| download | args-acf522e7bab50b24ec702b405b4e450b65f835cd.tar.zst args-acf522e7bab50b24ec702b405b4e450b65f835cd.zip | |
fix: fix ls_args_parse segfault on required positional args
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/tests.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/tests.c b/tests/tests.c index 78c8f24..0a136b1 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -113,6 +113,23 @@ TEST_CASE(too_many_positional_after_double_dash) { return 0; } +TEST_CASE(basic_args_positional_required_error) { + int help = 0; + const char* first; + ls_args args; + char* argv[] = { "./hello", "world", NULL }; + int argc = sizeof(argv) / sizeof(*argv) - 1; + + ls_args_init(&args); + ls_args_pos_string(&args, 0, &first, "First positional argument", LS_ARGS_REQUIRED); + + ASSERT(!ls_args_parse(&args, argc, argv)); + + ASSERT_STR_EQ(args.last_error, "Required positional argument not found (argument 0)"); + ls_args_free(&args); + return 0; +} + TEST_CASE(basic_args_positional_only_error) { int help = 0; const char* input; |
