@@ -19,7 +19,7 @@ ARGUS_OPTIONS(
1919 foo_options ,
2020 HELP_OPTION (),
2121 OPTION_FLAG ('v' , "verbose" , HELP ("Enable verbose output" )),
22- POSITIONAL_INT ("value" , HELP ("A numerical value" )),
22+ POSITIONAL_INT ("value" , HELP ("A numerical value" ), VALIDATOR ( V_RANGE ( -50 , 50 )) ),
2323)
2424
2525ARGUS_OPTIONS (
@@ -238,6 +238,21 @@ Test(subcommand_edge, subcommand_negative_number, .init = setup_subcommand)
238238 argus_free (& argus );
239239}
240240
241+ // Test Validator invalid value in subcommands
242+ Test (subcommand_edge , subcommand_invalid_value , .init = setup_subcommand )
243+ {
244+ char * argv [] = {"test" , "nested" , "foo" , "100" };
245+ int argc = sizeof (argv ) / sizeof (char * );
246+
247+ argus_t argus = argus_init (cmd_options , "test" , "1.0.0" );
248+ int status = argus_parse (& argus , argc , argv );
249+
250+ cr_assert_neq (status , ARGUS_SUCCESS , "Subcommand with invalid number should fail" );
251+ cr_assert (argus_has_command (& argus ), "argus_has_command should return true" );
252+
253+ argus_free (& argus );
254+ }
255+
241256// Helper function for format tests
242257void setup_error_redirect (void )
243258{
0 commit comments