mirror of
https://github.com/TokTok/c-toxcore
synced 2026-04-25 13:22:11 +00:00
21 lines
418 B
C++
21 lines
418 B
C++
#include "network.h"
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
namespace {
|
|
|
|
TEST(IpNtoa, DoesntWriteOutOfBounds) {
|
|
char ip_str[IP_NTOA_LEN];
|
|
IP ip;
|
|
ip.family = net_family_ipv6;
|
|
ip.ip.v6.uint64[0] = -1;
|
|
ip.ip.v6.uint64[1] = -1;
|
|
|
|
ip_ntoa(&ip, ip_str, sizeof(ip_str));
|
|
|
|
EXPECT_EQ(std::string(ip_str), "[ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]");
|
|
EXPECT_LT(std::string(ip_str).length(), IP_NTOA_LEN);
|
|
}
|
|
|
|
} // namespace
|