net-tools/tests/cli/handlers/test_handle_count.c
lohhiiccc f6af6473db test(cli/handlers): add unit tests for CLI handlers
- Add unit tests for handlers
- Update sources.mk to remove test_parse.c from test sources
- Fix in handle_size to set packet_size instead of count
2026-03-03 11:26:58 +01:00

23 lines
505 B
C

#include <criterion/criterion.h>
#include "cli.h"
/* Test 1: basic test */
Test(cli_handle_count, valid_number)
{
t_ping_config config = {0};
const char *arg = "42";
int ret = cli_handle_count(arg, &config);
cr_assert_eq(ret, CLI_SUCCESS);
cr_assert_eq(config.count, 42);
}
/* Test 2: invalid number */
Test(cli_handle_count, invalid_number)
{
t_ping_config config = {0};
const char *arg = "-42";
int ret = cli_handle_count(arg, &config);
cr_assert_eq(ret, CLI_ERROR);
}