1#include <cppunit/extensions/HelperMacros.h>
5class SocketUtils_TEST :
public CppUnit::TestFixture
7 CPPUNIT_TEST_SUITE( SocketUtils_TEST);
8 CPPUNIT_TEST( resolveHostname );
9 CPPUNIT_TEST( resolveService );
10 CPPUNIT_TEST( getNetworkInterfaces );
11 CPPUNIT_TEST( getInterfaceAddress );
12 CPPUNIT_TEST( getBroadcastAddress );
13 CPPUNIT_TEST( getNetmask );
14 CPPUNIT_TEST( getHardwareAddress );
15 CPPUNIT_TEST_SUITE_END();
22 void resolveHostname() {
24 std::string(
"127.0.0.1"),
28 void resolveService() {
50 void getNetworkInterfaces() {
52 CPPUNIT_ASSERT( list.size() >= 1 );
58 void getInterfaceAddress() {
60 std::string(
"127.0.0.1"),
64 void getBroadcastAddress() {
66 std::string(
"0.0.0.0"),
72 std::string(
"255.0.0.0"),
76 void getHardwareAddress() {
78 CPPUNIT_ASSERT( list.size() >= 2 );
80 CPPUNIT_ASSERT( mac.size() == 17);
CPPUNIT_TEST_SUITE_REGISTRATION(SocketUtils_TEST)
std::string getHardwareAddress(std::string_view interface)
Return the MAC address of the given network interfaces.
std::string getInterfaceAddress(std::string_view interface)
Return the IPv4 address of the given network interface.
uint16_t resolveService(const std::string &service, const std::string &protocol="tcp")
std::vector< std::string > getNetworkInterfaces()
Return a list of available network interfaces.
std::string getBroadcastAddress(std::string_view interface)
Return the IPv4 broadcast address of the given network interface.
std::string getNetmask(std::string_view interface)
Return the IPv4 netmask of the given network interface.
std::string resolveHostname(const std::string &hostname)