test: add test cases

This commit is contained in:
Nick Peng
2023-03-26 00:27:40 +08:00
parent 56d711a796
commit c90a85dfc7
25 changed files with 1177 additions and 39 deletions

View File

@@ -310,7 +310,7 @@ int parse_ip(const char *value, char *ip, int *port)
return 0;
}
static int _check_is_ipv4(const char *ip)
int check_is_ipv4(const char *ip)
{
const char *ptr = ip;
char c = 0;
@@ -344,7 +344,8 @@ static int _check_is_ipv4(const char *ip)
return 0;
}
static int _check_is_ipv6(const char *ip)
int check_is_ipv6(const char *ip)
{
const char *ptr = ip;
char c = 0;
@@ -394,10 +395,10 @@ int check_is_ipaddr(const char *ip)
{
if (strstr(ip, ".")) {
/* IPV4 */
return _check_is_ipv4(ip);
return check_is_ipv4(ip);
} else if (strstr(ip, ":")) {
/* IPV6 */
return _check_is_ipv6(ip);
return check_is_ipv6(ip);
}
return -1;
}