- 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
33 lines
694 B
C
33 lines
694 B
C
#include <criterion/criterion.h>
|
|
#include "cli.h"
|
|
|
|
/* Test 1: basic test */
|
|
Test(cli_handle_ttl, valid_number)
|
|
{
|
|
t_ping_config config = {0};
|
|
const char *arg = "255";
|
|
int ret = cli_handle_ttl(arg, &config);
|
|
|
|
cr_assert_eq(ret, CLI_SUCCESS);
|
|
cr_assert_eq(config.ttl, 255);
|
|
}
|
|
|
|
/* Test 2: invalid number */
|
|
Test(cli_handle_ttl, invalid_number)
|
|
{
|
|
t_ping_config config = {0};
|
|
const char *arg = "-1";
|
|
int ret = cli_handle_ttl(arg, &config);
|
|
|
|
cr_assert_eq(ret, CLI_ERROR);
|
|
}
|
|
|
|
/* Test 3: max test */
|
|
Test(cli_handle_ttl, limit_test)
|
|
{
|
|
t_ping_config config = {0};
|
|
const char *arg = "256";
|
|
int ret = cli_handle_ttl(arg, &config);
|
|
|
|
cr_assert_eq(ret, CLI_ERROR);
|
|
}
|