libcruft-util/test/hton.cpp

32 lines
543 B
C++
Raw Normal View History

2011-06-21 23:36:51 +10:00
2015-04-13 16:45:56 +10:00
#include "endian.hpp"
2011-06-21 23:36:51 +10:00
2015-04-13 16:45:56 +10:00
#include "debug.hpp"
#include "tap.hpp"
#include "platform.hpp"
2011-06-21 23:36:51 +10:00
#include <cstdlib>
#if defined(PLATFORM_WIN32)
#include <winsock2.h>
#else
#include <arpa/inet.h>
#include <netinet/in.h>
#endif
2011-06-21 23:36:51 +10:00
int
main (int, char **) {
2011-06-21 23:36:51 +10:00
uint16_t u16 = 0x1358;
uint32_t u32 = 0x12345678;
2012-05-11 12:34:21 +10:00
CHECK_EQ (htons (u16), hton (u16));
CHECK_EQ (htonl (u32), hton (u32));
2011-06-21 23:36:51 +10:00
2012-05-11 12:34:21 +10:00
CHECK_EQ (ntohs (u16), hton (u16));
CHECK_EQ (ntohl (u32), hton (u32));
2011-06-21 23:36:51 +10:00
2015-04-13 16:45:56 +10:00
util::TAP::logger tap;
tap.todo ("convert to TAP");
2011-06-21 23:36:51 +10:00
}