From 74cd9a86440f9f3ec8bc7d307e2a6f4a29ceefef Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Thu, 5 Mar 2020 21:28:52 +0100 Subject: [PATCH] ip4: add unit test for ip4addr_aton --- test/unit/ip4/test_ip4.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/unit/ip4/test_ip4.c b/test/unit/ip4/test_ip4.c index d663b2fe..7fa077fe 100644 --- a/test/unit/ip4/test_ip4.c +++ b/test/unit/ip4/test_ip4.c @@ -219,6 +219,22 @@ START_TEST(test_127_0_0_1) } END_TEST +START_TEST(test_ip4addr_aton) +{ + ip4_addr_t ip_addr; + + LWIP_UNUSED_ARG(_i); + + fail_unless(ip4addr_aton("192.168.0.1", &ip_addr) == 1); + fail_unless(ip4addr_aton("192.168.0.0001", &ip_addr) == 1); + fail_unless(ip4addr_aton("192.168.0.zzz", &ip_addr) == 0); + fail_unless(ip4addr_aton("192.168.1", &ip_addr) == 1); + fail_unless(ip4addr_aton("192.168.0xd3", &ip_addr) == 1); + fail_unless(ip4addr_aton("192.168.0xz5", &ip_addr) == 0); + fail_unless(ip4addr_aton("192.168.095", &ip_addr) == 0); +} +END_TEST + /** Create the suite including all tests for this module */ Suite * ip4_suite(void) @@ -226,6 +242,7 @@ ip4_suite(void) testfunc tests[] = { TESTFUNC(test_ip4_reass), TESTFUNC(test_127_0_0_1), + TESTFUNC(test_ip4addr_aton), }; return create_suite("IPv4", tests, sizeof(tests)/sizeof(testfunc), ip4_setup, ip4_teardown); }