38 lines
1,009 B
C
38 lines
1,009 B
C
#include <criterion/criterion.h>
|
|
#include <stdlib.h>
|
|
#include "ping/cli.h"
|
|
#include "internal/ping/parse_utils.h"
|
|
|
|
Test(cli_parse_destinations, no_destinations)
|
|
{
|
|
struct ping_config config = {0};
|
|
char *argv[] = {"ping"};
|
|
int argc = 1;
|
|
int ret = cli_parse_destinations(argc, argv, argc, &config);
|
|
|
|
cr_assert_eq(ret, CLI_ERROR);
|
|
}
|
|
|
|
Test(cli_parse_destinations, single_destination)
|
|
{
|
|
struct ping_config config = {0};
|
|
char *argv[] = {"ping", "127.0.0.1"};
|
|
int argc = 2;
|
|
int ret = cli_parse_destinations(argc, argv, 1, &config);
|
|
|
|
cr_assert_eq(ret, CLI_SUCCESS);
|
|
cr_assert_eq(config.nb_destinations, (size_t)1);
|
|
free(config.destinations);
|
|
}
|
|
|
|
Test(cli_parse_destinations, multiple_destinations)
|
|
{
|
|
struct ping_config config = {0};
|
|
char *argv[] = {"ping", "127.0.0.1", "127.0.0.2"};
|
|
int argc = 3;
|
|
int ret = cli_parse_destinations(argc, argv, 1, &config);
|
|
|
|
cr_assert_eq(ret, CLI_SUCCESS);
|
|
cr_assert_eq(config.nb_destinations, (size_t)2);
|
|
free(config.destinations);
|
|
}
|