mirror of
https://github.com/mfontanini/libtins
synced 2026-01-24 19:21:35 +01:00
Added HWAddress<>::operator[].
This commit is contained in:
@@ -244,6 +244,15 @@ public:
|
||||
oss << *this;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retrieves the i-th storage_type in this address.
|
||||
*
|
||||
* \param i The element to retrieve.
|
||||
*/
|
||||
storage_type operator[](size_t i) const {
|
||||
return buffer[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Writes this HWAddress in hex-notation to a std::ostream.
|
||||
|
||||
@@ -36,6 +36,12 @@ TEST_F(HWAddressTest, DistinctOperator) {
|
||||
EXPECT_NE(addr1, addr2);
|
||||
}
|
||||
|
||||
TEST_F(HWAddressTest, SubscriptOperator) {
|
||||
HWAddress<6> addr("00:01:02:03:04:05");
|
||||
for(size_t i = 0; i < addr.size(); ++i)
|
||||
EXPECT_EQ(addr[i], i);
|
||||
}
|
||||
|
||||
TEST_F(HWAddressTest, LessThanOperator) {
|
||||
HWAddress<6> addr1(byte_address), addr2(empty_addr);
|
||||
HWAddress<6> bcast = "ff:ff:ff:ff:ff:ff";
|
||||
|
||||
Reference in New Issue
Block a user