Add test for mac address
This commit is contained in:
parent
b929a8cfae
commit
af0b60da8c
3 changed files with 32 additions and 0 deletions
|
@ -80,6 +80,16 @@ public:
|
|||
return memcmp(byte,otherMac.byte,sizeof(byte))==0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override - Implements the comparison between mac address (not equal)
|
||||
* \param otherMac This is the other mac address to be compared with the local one.
|
||||
* \return true if the two addresses match.
|
||||
*/
|
||||
bool operator!= ( const mac_address& otherMac )
|
||||
{
|
||||
return !operator==(otherMac);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ foreach(testSrc ${TEST_SRC})
|
|||
|
||||
# link to Boost libraries AND your targets and dependencies
|
||||
target_link_libraries(${testName} ${Boost_LIBRARIES})
|
||||
target_link_libraries(${testName} network)
|
||||
|
||||
# Add test
|
||||
add_test(NAME ${testName}
|
||||
|
|
21
test/test_Macaddress.cpp
Normal file
21
test/test_Macaddress.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#define BOOST_TEST_DYN_LINK
|
||||
#define BOOST_TEST_MODULE "Mac address check"
|
||||
#include "../commons/macaddress.h"
|
||||
#include <boost/test/unit_test.hpp> //VERY IMPORTANT - include this last
|
||||
|
||||
BOOST_AUTO_TEST_CASE( mac_address_eq ) {
|
||||
network::mac_address a("AA:AA:AA:AA:AA:AA");
|
||||
network::mac_address b("AA:AA:AA:AA:AA:AA");
|
||||
BOOST_CHECK( a == b );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( mac_address_neq ) {
|
||||
network::mac_address a("AA:AA:AA:AA:AA:AA");
|
||||
network::mac_address b("BB:BB:BB:BB:BB:BB");
|
||||
BOOST_CHECK( a != b );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( mac_address_io ) {
|
||||
network::mac_address a("aa:aa:aa:aa:aa:aa");
|
||||
BOOST_CHECK_EQUAL( a.to_string(), "aa:aa:aa:aa:aa:aa" );
|
||||
}
|
Loading…
Reference in a new issue