diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/check_ipaddrcheck.c | 9 | ||||
| -rwxr-xr-x | tests/integration_tests.sh | 23 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/check_ipaddrcheck.c b/tests/check_ipaddrcheck.c index ad2b673..feb5a41 100644 --- a/tests/check_ipaddrcheck.c +++ b/tests/check_ipaddrcheck.c @@ -403,6 +403,14 @@ START_TEST (test_is_any_net) } END_TEST +START_TEST (test_is_ipv4_range) +{ + ck_assert_int_eq(is_ipv4_range("192.0.2.0-192.0.2.10", 0), RESULT_SUCCESS); + ck_assert_int_eq(is_ipv4_range("192.0.2.-", 0), RESULT_FAILURE); + ck_assert_int_eq(is_ipv4_range("192.0.2.99-192.0.2.11", 0), RESULT_FAILURE); +} +END_TEST + Suite *ipaddrcheck_suite(void) { @@ -433,6 +441,7 @@ Suite *ipaddrcheck_suite(void) tcase_add_test(tc_core, test_is_valid_intf_address); tcase_add_test(tc_core, test_is_any_host); tcase_add_test(tc_core, test_is_any_net); + tcase_add_test(tc_core, test_is_ipv4_range); suite_add_tcase(s, tc_core); diff --git a/tests/integration_tests.sh b/tests/integration_tests.sh index ccc7e3a..a679ea0 100755 --- a/tests/integration_tests.sh +++ b/tests/integration_tests.sh @@ -48,6 +48,16 @@ ipv4_cidr_negative=( 192.0.2.666/32 ) +ipv4_range_positive=( + 192.0.2.0-192.0.2.100 +) + +ipv4_range_negative=( + 192.0.2.-192.0.2.100 + 192.0.2.0- + 192.0.2.200-192.0.2.100 +) + ipv6_single_positive=( 2001:0db8:0000:0000:0000:ff00:0042:8329 2001:db8:0:0:0:ff00:42:8329 @@ -251,4 +261,17 @@ done # --is-ipv6-link-local # --is-valid-intf-address +# --is-ipv4-range +for range in \ + ${ipv4_range_positive[*]} +do + assert_raises "$IPADDRCHECK --is-ipv4-range $range" 0 +done + +for range in \ + ${ipv4_range_negative[*]} +do + assert_raises "$IPADDRCHECK --is-ipv4-range $range" 1 +done + assert_end ipaddrcheck_integration |
