Files
c-toxcore/toxcore/network_test.cc
T
jfreegman 3f4ea3d5fd Remove brackets from ip_ntoa ipv6 formatting
The brackets serve no purpose and make us do extra string
parsing when using the output for other things

Also removed a useless call to ip_ntoa in LAN_discovery.c
2022-01-29 15:29:14 -05:00

21 lines
416 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