Fix headers and linking for network tests
This commit is contained in:
parent
798ea55ec9
commit
0c4f9cb275
@ -32,6 +32,9 @@ TEST_BIN = \
|
||||
AM_DEFAULT_SOURCE_EXT = .cpp
|
||||
LDADD = $(builddir)/../libutil.la
|
||||
|
||||
hton_LDFLAGS = -lws2_32
|
||||
ip_LDFLAGS = -lws2_32
|
||||
|
||||
TESTS = $(TEST_BIN) json.pl
|
||||
check_PROGRAMS = $(TEST_BIN)
|
||||
EXTRA_DIST = json.pl
|
||||
|
@ -2,10 +2,15 @@
|
||||
#include "../endian.hpp"
|
||||
|
||||
#include "../debug.hpp"
|
||||
#include "../platform.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#if defined(PLATFORM_WIN32)
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
23
test/ip.cpp
23
test/ip.cpp
@ -2,11 +2,17 @@
|
||||
#include "../ip.hpp"
|
||||
|
||||
#include "../debug.hpp"
|
||||
#include "../platform.hpp"
|
||||
#include "../types.hpp"
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(PLATFORM_WIN32)
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -26,10 +32,17 @@ main (int, char **) {
|
||||
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);
|
||||
uint32_t mine = *(uint32_t*)(parsed.m_octets);
|
||||
|
||||
struct addrinfo *theirs;
|
||||
|
||||
int err = getaddrinfo (data[i].str, nullptr, nullptr, &theirs);
|
||||
CHECK_EQ (err, 0);
|
||||
|
||||
CHECK_EQ (mine, reinterpret_cast<sockaddr_in*> (theirs)->sin_addr.s_addr);
|
||||
|
||||
//CHECK_HARD (inet_pton (AF_INET, data[i].str, &theirs) == 1);
|
||||
//CHECK_HARD (theirs == mine);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
Loading…
Reference in New Issue
Block a user