diff --git a/test/ip.cpp b/test/ip.cpp index 78eab909..2b15df4d 100644 --- a/test/ip.cpp +++ b/test/ip.cpp @@ -4,6 +4,7 @@ #include "../debug.hpp" #include "../types.hpp" +#include #include @@ -21,8 +22,15 @@ main (int argc, char **argv) { { "127.0.0.1", { 127, 0, 0, 1 } } }; - for (unsigned int i = 0; i < elems (data); ++i) - check_hard (ipv4::ip::parse (data[i].str) == data[i].ip); + for (unsigned int i = 0; i < elems (data); ++i) { + ipv4::ip parsed (ipv4::ip::parse (data[i].str)); + check_hard (parsed == data[i].ip); + + uint32_t mine = *(uint32_t*)(parsed.m_octets), + theirs; + check_hard (inet_pton (AF_INET, data[i].str, &theirs) == 1); + check_hard (theirs == mine); + } return EXIT_SUCCESS; }