libcruft-util/test/hton.cpp

27 lines
418 B
C++
Raw Normal View History

2011-06-21 23:36:51 +10:00
2011-08-29 14:39:42 +10:00
#include "../endian.hpp"
2011-06-21 23:36:51 +10:00
#include "../debug.hpp"
#include <cstdlib>
#include <arpa/inet.h>
#include <netinet/in.h>
using namespace std;
int
main (int, char **) {
2011-06-21 23:36:51 +10:00
uint16_t u16 = 0x1358;
uint32_t u32 = 0x12345678;
check_eq (htons (u16), hton (u16));
check_eq (htonl (u32), hton (u32));
check_eq (ntohs (u16), hton (u16));
check_eq (ntohl (u32), hton (u32));
return EXIT_SUCCESS;
}