From 36b9956b3ad242a8265e6c493e23f21f2efa86b5 Mon Sep 17 00:00:00 2001 From: lohhiiccc <96543753+lohhiiccc@users.noreply.github.com> Date: Wed, 22 Apr 2026 23:23:14 +0200 Subject: [PATCH] test: replace single binary with per-module test binaries --- tests/Makefile.am | 94 +++++++------------ tests/cli/handlers/test_handle_count.c | 24 ----- tests/cli/handlers/test_handle_deadline.c | 22 ----- .../cli/handlers/test_handle_dont_fragment.c | 14 --- tests/cli/handlers/test_handle_flood.c | 15 --- tests/cli/handlers/test_handle_help.c | 13 --- tests/cli/handlers/test_handle_interval.c | 24 ----- tests/cli/handlers/test_handle_quiet.c | 15 --- tests/cli/handlers/test_handle_size.c | 34 ------- tests/cli/handlers/test_handle_timeout.c | 24 ----- tests/cli/handlers/test_handle_ttl.c | 34 ------- tests/cli/handlers/test_handle_verbose.c | 15 --- tests/cli/handlers/test_handle_version.c | 13 --- tests/cli/handlers/test_handler_map.c | 17 ---- .../cli/parse_utils/test_parse_destinations.c | 38 -------- tests/cli/parse_utils/test_parse_float.c | 69 -------------- tests/cli/parse_utils/test_parse_inet_addr.c | 21 ----- tests/cli/parse_utils/test_parse_int.c | 68 -------------- tests/test_main.c | 9 -- tests/test_support.c | 4 + 20 files changed, 39 insertions(+), 528 deletions(-) delete mode 100644 tests/cli/handlers/test_handle_count.c delete mode 100644 tests/cli/handlers/test_handle_deadline.c delete mode 100644 tests/cli/handlers/test_handle_dont_fragment.c delete mode 100644 tests/cli/handlers/test_handle_flood.c delete mode 100644 tests/cli/handlers/test_handle_help.c delete mode 100644 tests/cli/handlers/test_handle_interval.c delete mode 100644 tests/cli/handlers/test_handle_quiet.c delete mode 100644 tests/cli/handlers/test_handle_size.c delete mode 100644 tests/cli/handlers/test_handle_timeout.c delete mode 100644 tests/cli/handlers/test_handle_ttl.c delete mode 100644 tests/cli/handlers/test_handle_verbose.c delete mode 100644 tests/cli/handlers/test_handle_version.c delete mode 100644 tests/cli/handlers/test_handler_map.c delete mode 100644 tests/cli/parse_utils/test_parse_destinations.c delete mode 100644 tests/cli/parse_utils/test_parse_float.c delete mode 100644 tests/cli/parse_utils/test_parse_inet_addr.c delete mode 100644 tests/cli/parse_utils/test_parse_int.c delete mode 100644 tests/test_main.c create mode 100644 tests/test_support.c diff --git a/tests/Makefile.am b/tests/Makefile.am index 4911418..f9c2d21 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,59 +1,8 @@ -check_PROGRAMS = ft_ping_test +check_PROGRAMS = test_tracker test_stats test_send -ft_ping_test_SOURCES = \ - test_main.c \ - cli/handlers/test_handle_count.c \ - cli/handlers/test_handle_flood.c \ - cli/handlers/test_handle_help.c \ - cli/handlers/test_handle_interval.c \ - cli/handlers/test_handle_quiet.c \ - cli/handlers/test_handler_map.c \ - cli/handlers/test_handle_size.c \ - cli/handlers/test_handle_timeout.c \ - cli/handlers/test_handle_ttl.c \ - cli/handlers/test_handle_version.c \ - cli/handlers/test_handle_verbose.c \ - cli/handlers/test_handle_dont_fragment.c \ - cli/handlers/test_handle_deadline.c \ - cli/parse_utils/test_parse_int.c \ - cli/parse_utils/test_parse_float.c \ - cli/parse_utils/test_parse_inet_addr.c \ - cli/parse_utils/test_parse_destinations.c \ - ping/stats/test_stats.c \ - ping/tracker/test_tracker.c \ - $(top_srcdir)/src/ping/cli/parse.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_count.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_dont_fragment.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_deadline.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_flood.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_help.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_interval.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_quiet.c \ - $(top_srcdir)/src/ping/cli/handlers/option_map.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_size.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_timeout.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_ttl.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_version.c \ - $(top_srcdir)/src/ping/cli/handlers/handle_verbose.c \ - $(top_srcdir)/src/ping/cli/parse_utils/parse_inet_addr.c \ - $(top_srcdir)/src/ping/cli/parse_utils/parse_destinations.c \ - $(top_srcdir)/src/ping/cli/config_free.c \ - $(top_srcdir)/src/ping/cli/messages/help.c \ - $(top_srcdir)/src/ping/cli/messages/version.c \ - $(top_srcdir)/src/ping/cli/messages/error.c \ - $(top_srcdir)/src/ping/tracker/init.c \ - $(top_srcdir)/src/ping/tracker/record_send.c \ - $(top_srcdir)/src/ping/tracker/record_recv.c \ - $(top_srcdir)/src/ping/stats/stats_get.c \ - $(top_srcdir)/src/ping/stats/stats_init.c \ - $(top_srcdir)/src/ping/stats/stats_update.c - -ft_ping_test_CPPFLAGS = \ - -I $(top_srcdir)/includes \ - -I $(top_srcdir)/libicmp/includes \ - -I $(top_srcdir)/libcli/include \ - -I $(top_srcdir)/tests \ - -D_GNU_SOURCE +test_tracker_SOURCES = test_support.c ping/tracker/test_tracker.c +test_stats_SOURCES = test_support.c ping/stats/test_stats.c +test_send_SOURCES = test_support.c send/test_do_send.c BASE_CFLAGS = -std=c99 $(STRICT_CFLAGS) @@ -69,15 +18,42 @@ else SANITIZER_FLAGS = endif -ft_ping_test_CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS) $(SANITIZER_FLAGS) -ft_ping_test_LDFLAGS = $(SANITIZER_FLAGS) -ft_ping_test_LDADD = \ +TEST_CPPFLAGS = \ + -I $(top_srcdir)/includes \ + -I $(top_srcdir)/libicmp/includes \ + -I $(top_srcdir)/libcli/include \ + -I $(top_srcdir)/tests \ + -D_GNU_SOURCE + +TEST_CFLAGS = $(BASE_CFLAGS) $(EXTRA_CFLAGS) $(SANITIZER_FLAGS) + +TEST_LDADD = \ + $(top_builddir)/src/ping/libping_core.la \ $(top_srcdir)/libicmp/libicmp.a \ $(top_builddir)/libcli/src/libcli.la \ $(CRITERION_LIBS) \ -lm -TESTS = ft_ping_test +test_tracker_CPPFLAGS = $(TEST_CPPFLAGS) +test_tracker_CFLAGS = $(TEST_CFLAGS) +test_tracker_LDFLAGS = $(SANITIZER_FLAGS) +test_tracker_LDADD = $(TEST_LDADD) + +test_stats_CPPFLAGS = $(TEST_CPPFLAGS) +test_stats_CFLAGS = $(TEST_CFLAGS) +test_stats_LDFLAGS = $(SANITIZER_FLAGS) +test_stats_LDADD = $(TEST_LDADD) + +test_send_CPPFLAGS = $(TEST_CPPFLAGS) +test_send_CFLAGS = $(TEST_CFLAGS) +test_send_LDFLAGS = $(SANITIZER_FLAGS) \ + -Wl,--wrap=icmp_send_echo \ + -Wl,--wrap=icmp_should_retry \ + -Wl,--wrap=icmp_strerror \ + -Wl,--wrap=ping_scheduler_arm +test_send_LDADD = $(TEST_LDADD) + +TESTS = test_tracker test_stats test_send # Version header needed by test_main.c BUILT_SOURCES = $(top_srcdir)/includes/version_gen.h diff --git a/tests/cli/handlers/test_handle_count.c b/tests/cli/handlers/test_handle_count.c deleted file mode 100644 index 14c359e..0000000 --- a/tests/cli/handlers/test_handle_count.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include "ping/cli.h" -#include "internal/ping/cli_handlers.h" - -/* Test 1: basic test */ -Test(cli_handle_count, valid_number) -{ - struct 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) -{ - struct ping_config config = {0}; - const char *arg = "-42"; - int ret = cli_handle_count(arg, &config); - - cr_assert_eq(ret, CLI_ERROR); -} diff --git a/tests/cli/handlers/test_handle_deadline.c b/tests/cli/handlers/test_handle_deadline.c deleted file mode 100644 index d253da3..0000000 --- a/tests/cli/handlers/test_handle_deadline.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include "ping/cli.h" -#include "internal/ping/cli_handlers.h" - -Test(cli_handle_deadline, valid_number) -{ - struct ping_config config = {0}; - const char *arg = "1.5"; - int ret = cli_handle_deadline(arg, &config); - - cr_assert_eq(ret, CLI_SUCCESS); - cr_assert_float_eq(config.deadline, 1.5, .001); -} - -Test(cli_handle_deadline, invalid_number) -{ - struct ping_config config = {0}; - const char *arg = "-1"; - int ret = cli_handle_deadline(arg, &config); - - cr_assert_eq(ret, CLI_ERROR); -} diff --git a/tests/cli/handlers/test_handle_dont_fragment.c b/tests/cli/handlers/test_handle_dont_fragment.c deleted file mode 100644 index a1b40d9..0000000 --- a/tests/cli/handlers/test_handle_dont_fragment.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include "ping/cli.h" -#include "ping/ft_ping_flags.h" -#include "internal/ping/cli_handlers.h" - -Test(handle_dont_fragment, flag_test) -{ - struct ping_config config = {0}; - const char *arg = ""; - const int ret = cli_handle_dont_fragment(arg, &config); - - cr_assert(HAS_FLAG(config.flags, FLAG_DONT_FRAGMENT)); - cr_assert_eq(ret, CLI_SUCCESS); -} diff --git a/tests/cli/handlers/test_handle_flood.c b/tests/cli/handlers/test_handle_flood.c deleted file mode 100644 index 509dfb6..0000000 --- a/tests/cli/handlers/test_handle_flood.c +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include "ping/cli.h" -#include "internal/ping/cli_handlers.h" -#include "ping/ft_ping_flags.h" - -/* Test 1: test flag*/ -Test(handle_flood, flag_test) -{ - struct ping_config config = {0}; - const char *arg = ""; - const int ret = cli_handle_flood(arg, &config); - - cr_assert(HAS_FLAG(config.flags, FLAG_FLOOD)); - cr_assert_eq(ret, CLI_SUCCESS); -} diff --git a/tests/cli/handlers/test_handle_help.c b/tests/cli/handlers/test_handle_help.c deleted file mode 100644 index 38fdd69..0000000 --- a/tests/cli/handlers/test_handle_help.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include "ping/cli.h" -#include "internal/ping/cli_handlers.h" - -/* Test 1: exit code test */ -Test(handle_help, exit_code) -{ - struct ping_config config = {0}; - const char *arg = ""; - int ret = cli_handle_help(arg, &config); - - cr_assert_eq(ret, CLI_EXIT_SUCCESS); -} diff --git a/tests/cli/handlers/test_handle_interval.c b/tests/cli/handlers/test_handle_interval.c deleted file mode 100644 index 3f15c26..0000000 --- a/tests/cli/handlers/test_handle_interval.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include "ping/cli.h" -#include "internal/ping/cli_handlers.h" - -/* Test 1: basic test */ -Test(cli_handle_interval, valid_number) -{ - struct ping_config config = {0}; - const char *arg = ".42"; - int ret = cli_handle_interval(arg, &config); - - cr_assert_eq(ret, CLI_SUCCESS); - cr_assert_float_eq(config.interval, .42, .001); -} - -/* Test 2: invalid number */ -Test(cli_handle_interval, invalid_number) -{ - struct ping_config config = {0}; - const char *arg = "-42"; - int ret = cli_handle_interval(arg, &config); - - cr_assert_eq(ret, CLI_ERROR); -} diff --git a/tests/cli/handlers/test_handle_quiet.c b/tests/cli/handlers/test_handle_quiet.c deleted file mode 100644 index 4091044..0000000 --- a/tests/cli/handlers/test_handle_quiet.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "ping/cli.h" -#include "ping/ft_ping_flags.h" -#include "internal/ping/cli_handlers.h" -#include - -/* Test 1: test flag*/ -Test(handle_quiet, flag_test) -{ - struct ping_config config = {0}; - const char *arg = ""; - const int ret = cli_handle_quiet(arg, &config); - - cr_assert(HAS_FLAG(config.flags, FLAG_QUIET)); - cr_assert_eq(ret, CLI_SUCCESS); -} diff --git a/tests/cli/handlers/test_handle_size.c b/tests/cli/handlers/test_handle_size.c deleted file mode 100644 index c8eb35f..0000000 --- a/tests/cli/handlers/test_handle_size.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include "ping/cli.h" -#include "internal/ping/cli_handlers.h" - -/* Test 1: basic test */ -Test(cli_handle_size, valid_number) -{ - struct ping_config config = {0}; - const char *arg = "65527"; - int ret = cli_handle_size(arg, &config); - - cr_assert_eq(ret, CLI_SUCCESS); - cr_assert_eq(config.packet_size, 65527); -} - -/* Test 2: invalid number */ -Test(cli_handle_size, invalid_number) -{ - struct ping_config config = {0}; - const char *arg = "-42"; - int ret = cli_handle_size(arg, &config); - - cr_assert_eq(ret, CLI_ERROR); -} - -/* Test 3: max test */ -Test(cli_handle_size, limit_test) -{ - struct ping_config config = {0}; - const char *arg = "65528"; - int ret = cli_handle_size(arg, &config); - - cr_assert_eq(ret, CLI_ERROR); -} diff --git a/tests/cli/handlers/test_handle_timeout.c b/tests/cli/handlers/test_handle_timeout.c deleted file mode 100644 index 2f70eec..0000000 --- a/tests/cli/handlers/test_handle_timeout.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include "ping/cli.h" -#include "internal/ping/cli_handlers.h" - -/* Test 1: basic test */ -Test(cli_handle_timeout, valid_number) -{ - struct 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) -{ - struct ping_config config = {0}; - const char *arg = "-42"; - int ret = cli_handle_timeout(arg, &config); - - cr_assert_eq(ret, CLI_ERROR); -} diff --git a/tests/cli/handlers/test_handle_ttl.c b/tests/cli/handlers/test_handle_ttl.c deleted file mode 100644 index 471d560..0000000 --- a/tests/cli/handlers/test_handle_ttl.c +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include "ping/cli.h" -#include "internal/ping/cli_handlers.h" - -/* Test 1: basic test */ -Test(cli_handle_ttl, valid_number) -{ - struct 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) -{ - struct 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) -{ - struct ping_config config = {0}; - const char *arg = "256"; - int ret = cli_handle_ttl(arg, &config); - - cr_assert_eq(ret, CLI_ERROR); -} diff --git a/tests/cli/handlers/test_handle_verbose.c b/tests/cli/handlers/test_handle_verbose.c deleted file mode 100644 index db09fff..0000000 --- a/tests/cli/handlers/test_handle_verbose.c +++ /dev/null @@ -1,15 +0,0 @@ -#include "ping/cli.h" -#include "ping/ft_ping_flags.h" -#include "internal/ping/cli_handlers.h" -#include - -/* Test 1: test flag*/ -Test(handle_verbose, flag_test) -{ - struct ping_config config = {0}; - const char *arg = ""; - const int ret = cli_handle_verbose(arg, &config); - - cr_assert(HAS_FLAG(config.flags, FLAG_VERBOSE)); - cr_assert_eq(ret, CLI_SUCCESS); -} diff --git a/tests/cli/handlers/test_handle_version.c b/tests/cli/handlers/test_handle_version.c deleted file mode 100644 index 2ae1397..0000000 --- a/tests/cli/handlers/test_handle_version.c +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include "ping/cli.h" -#include "internal/ping/cli_handlers.h" - -/* Test 1: exit code test */ -Test(handle_version, exit_code) -{ - struct ping_config config = {0}; - const char *arg = ""; - int ret = cli_handle_version(arg, &config); - - cr_assert_eq(ret, CLI_EXIT_SUCCESS); -} diff --git a/tests/cli/handlers/test_handler_map.c b/tests/cli/handlers/test_handler_map.c deleted file mode 100644 index 6ca27b1..0000000 --- a/tests/cli/handlers/test_handler_map.c +++ /dev/null @@ -1,17 +0,0 @@ -#include "internal/ping/cli_handlers.h" -#include -#include - -/* Test 1: g_options is null terminated */ -Test(_test_handler_map, always_pass) -{ - size_t i = 0; - for (i = 0; NULL != g_options[i].description; ++i); - - cr_assert(g_options[i].description == NULL); - cr_assert(g_options[i].arg_type == 0); - cr_assert(g_options[i].handler == NULL); - cr_assert(g_options[i].has_arg == 0); - cr_assert(g_options[i].long_opt == NULL); - cr_assert(g_options[i].short_opt == 0); -} diff --git a/tests/cli/parse_utils/test_parse_destinations.c b/tests/cli/parse_utils/test_parse_destinations.c deleted file mode 100644 index b8eebbe..0000000 --- a/tests/cli/parse_utils/test_parse_destinations.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#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); -} diff --git a/tests/cli/parse_utils/test_parse_float.c b/tests/cli/parse_utils/test_parse_float.c deleted file mode 100644 index 453b6c8..0000000 --- a/tests/cli/parse_utils/test_parse_float.c +++ /dev/null @@ -1,69 +0,0 @@ -#include -#include "internal/cli/parse_utils.h" - -/* Test 1: Valid simple number */ -Test(parse_float, valid_number) -{ - float result; - int ret = cli_parse_float("42.42", &result); - - cr_assert_eq(ret, 0); - cr_assert_float_eq(result, 42.42, 0.0001); -} - -/* Test 2: Zero */ -Test(parse_float, zero) -{ - float result; - int ret = cli_parse_float("0", &result); - - cr_assert_eq(ret, 0); - cr_assert_float_eq(result, 0, 0.0001); -} - -/* Test 3: NULL pointer */ -Test(parse_float, null_pointer) -{ - float result; - int ret = cli_parse_float(NULL, &result); - - cr_assert_eq(ret, 1); -} - -/* Test 4: Empty string */ -Test(parse_float, empty_string) -{ - float result; - int ret = cli_parse_float("", &result); - - cr_assert_eq(ret, 1); -} - -/* Test 5: Negative number (cli_parse_float accepts negatives; use cli_parse_ufloat to reject) */ -Test(parse_float, negative_number) -{ - float result; - int ret = cli_parse_float("-42", &result); - - cr_assert_eq(ret, 0); - cr_assert_float_eq(result, -42.0f, 0.001f); -} - -/* Test 6: Invalid characters */ -Test(parse_float, invalid_characters) -{ - float result; - int ret = cli_parse_float("42abc", &result); - - cr_assert_eq(ret, 1); -} - -/* Test 7: Dot + number */ -Test(parse_float, dot) -{ - float result; - int ret = cli_parse_float(".42", &result); - - cr_assert_eq(ret, 0); - cr_assert_float_eq(result, 0.42, 0.0001); -} diff --git a/tests/cli/parse_utils/test_parse_inet_addr.c b/tests/cli/parse_utils/test_parse_inet_addr.c deleted file mode 100644 index 07f00ec..0000000 --- a/tests/cli/parse_utils/test_parse_inet_addr.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include "ping/ping.h" -#include "internal/ping/parse_utils.h" - -Test(cli_parse_inet_addr, valid_ip) -{ - struct destinations out = {0}; - int ret = cli_parse_inet_addr("127.0.0.1", &out); - - cr_assert_eq(ret, 0); - cr_assert_str_eq(out.dom, "127.0.0.1"); -} - -Test(cli_parse_inet_addr, invalid_host) -{ - struct destinations out = {0}; - int ret = cli_parse_inet_addr("invalid.host.local", &out); - - cr_assert_eq(ret, 1); -} diff --git a/tests/cli/parse_utils/test_parse_int.c b/tests/cli/parse_utils/test_parse_int.c deleted file mode 100644 index 901a6b0..0000000 --- a/tests/cli/parse_utils/test_parse_int.c +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include -#include "internal/cli/parse_utils.h" - -/* Test 1: Valid simple number */ -Test(parse_uint64, valid_number) -{ - uint64_t result; - int ret = cli_parse_uint64("42", &result); - - cr_assert_eq(ret, 0); - cr_assert_eq(result, 42); -} - -/* Test 2: Zero */ -Test(parse_uint64, zero) -{ - uint64_t result; - int ret = cli_parse_uint64("0", &result); - - cr_assert_eq(ret, 0); - cr_assert_eq(result, 0); -} - -/* Test 3: NULL pointer */ -Test(parse_uint64, null_pointer) -{ - uint64_t result; - int ret = cli_parse_uint64(NULL, &result); - - cr_assert_eq(ret, 1); -} - -/* Test 4: Empty string */ -Test(parse_uint64, empty_string) -{ - uint64_t result; - int ret = cli_parse_uint64("", &result); - - cr_assert_eq(ret, 1); -} - -/* Test 5: Negative number */ -Test(parse_uint64, negative_number) -{ - uint64_t result; - int ret = cli_parse_uint64("-42", &result); - - cr_assert_eq(ret, 1); -} - -/* Test 6: Invalid characters */ -Test(parse_uint64, invalid_characters) -{ - uint64_t result; - int ret = cli_parse_uint64("42abc", &result); - - cr_assert_eq(ret, 1); -} - -/* Test 7: Overflow */ -Test(parse_uint64, overflow) -{ - uint64_t result; - int ret = cli_parse_uint64("18446744073709551616", &result); - - cr_assert_eq(ret, 1); -} diff --git a/tests/test_main.c b/tests/test_main.c deleted file mode 100644 index e9d3d62..0000000 --- a/tests/test_main.c +++ /dev/null @@ -1,9 +0,0 @@ -#include -#include "version_gen.h" - -char *g_prog_name = "ft_ping"; -Test(dummy, always_pass) -{ - cr_assert(1, "Hello, world!"); -} - diff --git a/tests/test_support.c b/tests/test_support.c new file mode 100644 index 0000000..b825546 --- /dev/null +++ b/tests/test_support.c @@ -0,0 +1,4 @@ +#include "version_gen.h" + +char *g_prog_name = "ft_ping"; +