- Move CLI internal headers to `includes/internal/cli/` - Split CLI handler and parsing declarations across dedicated internal headers - Move handler map to `option_map.c` and properly update references - Relocate CLI utility source and test files from `utils` to `parse_utils` - Refactor `cli.h` to only expose the public interface, move internal typedefs/functions out - Update build system: add conditional git commit detection
34 lines
749 B
C
34 lines
749 B
C
#include <criterion/criterion.h>
|
|
#include "cli.h"
|
|
#include "internal/arg_handler.h"
|
|
|
|
/* Test 1: basic test */
|
|
Test(cli_handle_size, valid_number)
|
|
{
|
|
t_ping_config config = {0};
|
|
const char *arg = "65527";
|
|
int ret = cli_handle_size(arg, &config);
|
|
|
|
cr_assert_eq(ret, CLI_SUCCESS);
|
|
cr_assert_eq(config.packet_size, 65527);
|
|
}
|
|
|
|
/* Test 2: invalid number */
|
|
Test(cli_handle_size, invalid_number)
|
|
{
|
|
t_ping_config config = {0};
|
|
const char *arg = "-42";
|
|
int ret = cli_handle_size(arg, &config);
|
|
|
|
cr_assert_eq(ret, CLI_ERROR);
|
|
}
|
|
|
|
/* Test 3: max test */
|
|
Test(cli_handle_size, limit_test)
|
|
{
|
|
t_ping_config config = {0};
|
|
const char *arg = "65528";
|
|
int ret = cli_handle_size(arg, &config);
|
|
|
|
cr_assert_eq(ret, CLI_ERROR);
|
|
}
|