1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-25 11:41:35 +01:00

Moved endianness change functions to endianness.h.

This commit is contained in:
Matias Fontanini
2012-09-03 23:58:43 -03:00
parent 279940c398
commit 832a79a1e1
39 changed files with 482 additions and 557 deletions

View File

@@ -2,6 +2,7 @@
#include <stdexcept>
#include <gtest/gtest.h>
#include "utils.h"
#include "endianness.h"
#include "ipaddress.h"
using namespace Tins;
@@ -65,33 +66,6 @@ TEST_F(UtilsTest, ResolveIp) {
}
TEST_F(UtilsTest, NetToHostS) {
uint16_t a = 0x01FE;
uint16_t b = Utils::net_to_host_s(a);
EXPECT_EQ(b, 0xFE01);
EXPECT_EQ(a, Utils::net_to_host_s(b));
}
TEST_F(UtilsTest, NetToHostL) {
uint32_t a = 0x0102CDFE;
uint32_t b = Utils::net_to_host_l(a);
EXPECT_EQ(b, 0xFECD0201);
EXPECT_EQ(a, Utils::net_to_host_l(b));
}
TEST_F(UtilsTest, NetToHostLL) {
uint64_t a = 0x0102030489ABCDFE;
uint64_t b = Utils::net_to_host_ll(a);
EXPECT_EQ(b, 0xFECDAB8904030201);
EXPECT_EQ(a, Utils::net_to_host_ll(b));
}
TEST_F(UtilsTest, Crc32) {
uint32_t crc = Utils::crc32(data, data_len);