From 2e2a255a9de54b1ffb68611b68f9c8ed9e34d69e Mon Sep 17 00:00:00 2001 From: Pierre-Luc Boily Date: Mon, 6 Mar 2023 10:41:34 -0500 Subject: [PATCH] add test for the new function isValidIpAddress --- test/IXSocketTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/IXSocketTest.cpp b/test/IXSocketTest.cpp index ca423706..f7390c8b 100644 --- a/test/IXSocketTest.cpp +++ b/test/IXSocketTest.cpp @@ -95,4 +95,19 @@ TEST_CASE("socket", "[socket]") testSocket(host, port, request, socket, expectedStatus, timeoutSecs); } #endif + +TEST_CASE("isValidIpAddress") { + // Valid IPv4 addresses + CHECK(isValidIpAddress("127.0.0.1")); + CHECK(isValidIpAddress("192.168.0.1")); + CHECK(isValidIpAddress("10.0.0.1")); + CHECK(isValidIpAddress("172.16.0.1")); + + // Invalid IPv4 addresses + CHECK(!isValidIpAddress("256.0.0.1")); + CHECK(!isValidIpAddress("1.2.3.4.5")); + CHECK(!isValidIpAddress("192.168.0.")); + CHECK(!isValidIpAddress("192.168.0.-1")); + CHECK(!isValidIpAddress("192.168.0.256")); +} }