- 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
23 lines
505 B
C
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);
|
|
}
|