1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-29 13:04:28 +01:00

Added HWAddress class.

This commit is contained in:
Matias Fontanini
2012-08-07 12:05:05 -03:00
parent 4af3d3c697
commit b8f39f1291
2 changed files with 155 additions and 0 deletions

38
tests/src/hwaddress.cpp Normal file
View File

@@ -0,0 +1,38 @@
#include <gtest/gtest.h>
#include <algorithm>
#include <string>
#include <sstream>
#include <stdint.h>
#include "hwaddress.h"
using namespace Tins;
class HWAddressTest : public testing::Test {
public:
static const std::string address;
static const uint8_t *byte_address, *empty_addr;
};
const std::string HWAddressTest::address = "00:de:ad:be:ef:00";
const uint8_t *HWAddressTest::byte_address = (const uint8_t*)"\x00\xde\xad\xbe\xef\x00",
*HWAddressTest::empty_addr = (const uint8_t*)"\x00\x00\x00\x00\x00\x00";
TEST_F(HWAddressTest, DefaultConstructor) {
HWAddress<6> addr;
EXPECT_TRUE(std::equal(addr.begin(), addr.end(), empty_addr));
}
TEST_F(HWAddressTest, ConstructorFromAddress) {
HWAddress<6> addr(address);
EXPECT_TRUE(std::equal(addr.begin(), addr.end(), byte_address));
}
TEST_F(HWAddressTest, OutputOperator) {
HWAddress<6> addr(address);
std::ostringstream oss;
oss << addr;
EXPECT_EQ(oss.str(), address);
}