Skip to content

Commit

Permalink
LocalAddrMAC: rename toMAC to toBytes and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidB137 committed Sep 8, 2024
1 parent 986f8f9 commit 04d8841
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/kvik/local_addr_mac.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace kvik
*
* @param mac MAC address storage pointer
*/
void toMAC(uint8_t *mac) const;
void toBytes(uint8_t *mac) const;
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/common/local_addr_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace kvik
return LocalAddrMAC(mac);
}

void LocalAddrMAC::toMAC(uint8_t *mac) const
void LocalAddrMAC::toBytes(uint8_t *mac) const
{
for (unsigned i = 0; i < addr.size(); i++)
{
Expand Down
11 changes: 11 additions & 0 deletions test/tests/local_addr_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,14 @@ TEST_CASE("String representation", "[LocalAddrMAC]")
uint8_t mac[] = {0x00, 0x11, 0x23, 0x00, 0x55, 0xFF};
REQUIRE(LocalAddrMAC(mac).toString() == "0011230055ff");
}

TEST_CASE("To bytes", "[LocalAddrMAC]")
{
uint8_t mac[] = {0x00, 0x11, 0x23, 0x00, 0x55, 0xFF};
uint8_t mac2[6];
LocalAddrMAC(mac).toBytes(mac2);
for (size_t i = 0; i < 6; i++)
{
CHECK(mac[i] == mac2[i]);
}
}

0 comments on commit 04d8841

Please sign in to comment.