15 #include <gtest/gtest.h> 25 uint ip_uint[4] = {0};
28 EXPECT_TRUE(testing::internal::ArrayEq(ip_uint, {1, 1, 1, 1}));
36 EXPECT_TRUE(testing::internal::ArrayEq(ip_uint, {127, 220, 4, 32}));
44 EXPECT_TRUE(testing::internal::ArrayEq(ip_uint, {0, 0, 0, 0}));
52 EXPECT_TRUE(testing::internal::ArrayEq(ip_uint, {123, 0, 0, 0}));
60 EXPECT_TRUE(testing::internal::ArrayEq(ip_uint, {0, 0, 0, 0}));
68 EXPECT_TRUE(testing::internal::ArrayEq(ip_uint, {239, 64, 73, 0}));
92 "The numbers on the ip are not representable by 8 bits.");
94 "The IP is not in the specified range. Hover over the parameterto see the range.");
99 int main(
int argc,
char** argv) {
100 testing::InitGoogleTest(&argc, argv);
101 return RUN_ALL_TESTS();
bool ipv4_string_to_uint(std::string ip_string, uint *ip_uint)
Converts a IPv4 in a string to a array of unsigned integers, where the most significant byte of the I...
IPValidation
Type used to validate a IP string.
std::string get_error_msg(IPValidation error)
Get the error msg based on the validation type.
IPValidation check_valid_ip(std::string ip, std::string min_ip, std::string max_ip)
Checks if a IP is valid and is in the specified range.