- 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
529 B
C
23 lines
529 B
C
#include <criterion/criterion.h>
|
|
#include "cli.h"
|
|
|
|
/* Test 1: basic test */
|
|
Test(cli_handle_timeout, valid_number)
|
|
{
|
|
t_ping_config config = {0};
|
|
const char *arg = ".42";
|
|
int ret = cli_handle_timeout(arg, &config);
|
|
|
|
cr_assert_eq(ret, CLI_SUCCESS);
|
|
cr_assert_float_eq(config.timeout, .42, .001);
|
|
}
|
|
|
|
/* Test 2: invalid number */
|
|
Test(cli_handle_timeout, invalid_number)
|
|
{
|
|
t_ping_config config = {0};
|
|
const char *arg = "-42";
|
|
int ret = cli_handle_timeout(arg, &config);
|
|
|
|
cr_assert_eq(ret, CLI_ERROR);
|
|
}
|