diff --git a/UNITTESTS/features/netsocket/PPPInterface/test_PPPInterface.cpp b/UNITTESTS/features/netsocket/PPPInterface/test_PPPInterface.cpp index 003ff846b4..ef493ae35f 100644 --- a/UNITTESTS/features/netsocket/PPPInterface/test_PPPInterface.cpp +++ b/UNITTESTS/features/netsocket/PPPInterface/test_PPPInterface.cpp @@ -178,17 +178,21 @@ TEST_F(TestPPPInterface, disconnect) TEST_F(TestPPPInterface, set_network) { - char ipAddress[NSAPI_IPv4_SIZE] = "127.0.0.1"; - char netmask[NSAPI_IPv4_SIZE] = "255.255.0.0"; - char gateway[NSAPI_IPv4_SIZE] = "127.0.0.2"; + SocketAddress ipAddress("127.0.0.1"); + SocketAddress netmask("255.255.0.0"); + SocketAddress gateway("127.0.0.2"); const char *ipAddressArg; const char *netmaskArg; const char *gatewayArg; - EXPECT_EQ(0, iface->get_ip_address()); - EXPECT_EQ(0, iface->get_netmask()); - EXPECT_EQ(0, iface->get_gateway()); + SocketAddress ipAddr; + SocketAddress netmaskAddr; + SocketAddress gatewayAddr; + + EXPECT_EQ(NSAPI_ERROR_NO_CONNECTION, iface->get_ip_address(&ipAddr)); + EXPECT_EQ(NSAPI_ERROR_NO_CONNECTION, iface->get_netmask(&netmaskAddr)); + EXPECT_EQ(NSAPI_ERROR_NO_CONNECTION, iface->get_gateway(&gatewayAddr)); EXPECT_CALL(*pppMock, set_stream(_)); EXPECT_CALL(*pppMock, set_ip_stack(_)); @@ -213,25 +217,28 @@ TEST_F(TestPPPInterface, set_network) Return(NSAPI_ERROR_OK))); EXPECT_EQ(NSAPI_ERROR_OK, iface->connect()); // Check the contents of the stored pointer arguments. - EXPECT_TRUE(0 == strcmp(ipAddress, ipAddressArg)); - EXPECT_TRUE(0 == strcmp(netmask, netmaskArg)); - EXPECT_TRUE(0 == strcmp(gateway, gatewayArg)); + EXPECT_TRUE(0 == strcmp(ipAddress.get_ip_address(), ipAddressArg)); + EXPECT_TRUE(0 == strcmp(netmask.get_ip_address(), netmaskArg)); + EXPECT_TRUE(0 == strcmp(gateway.get_ip_address(), gatewayArg)); // Testing the getters makes sense now. - EXPECT_CALL(*netStackIface, get_ip_address(_, _)) + EXPECT_CALL(*netStackIface, get_ip_address(_)) .Times(1) - .WillOnce(DoAll(SetArgPointee<0>(*ipAddress), Return(ipAddress))); - EXPECT_EQ(std::string(ipAddress), std::string(iface->get_ip_address())); + .WillOnce(DoAll(SetArgPointee<0>(ipAddress), Return(NSAPI_ERROR_OK))); + EXPECT_EQ(NSAPI_ERROR_OK, iface->get_ip_address(&ipAddr)); + EXPECT_EQ(ipAddress, ipAddr); - EXPECT_CALL(*netStackIface, get_netmask(_, _)) + EXPECT_CALL(*netStackIface, get_netmask(_)) .Times(1) - .WillOnce(DoAll(SetArgPointee<0>(*netmask), Return(netmask))); - EXPECT_EQ(std::string(netmask), std::string(iface->get_netmask())); + .WillOnce(DoAll(SetArgPointee<0>(netmask), Return(NSAPI_ERROR_OK))); + EXPECT_EQ(NSAPI_ERROR_OK, iface->get_netmask(&netmaskAddr)); + EXPECT_EQ(netmask, netmaskAddr); - EXPECT_CALL(*netStackIface, get_gateway(_, _)) + EXPECT_CALL(*netStackIface, get_gateway(_)) .Times(1) - .WillOnce(DoAll(SetArgPointee<0>(*gateway), Return(gateway))); - EXPECT_EQ(std::string(gateway), std::string(iface->get_gateway())); + .WillOnce(DoAll(SetArgPointee<0>(gateway), Return(NSAPI_ERROR_OK))); + EXPECT_EQ(NSAPI_ERROR_OK, iface->get_gateway(&gatewayAddr)); + EXPECT_EQ(gateway, gatewayAddr); } TEST_F(TestPPPInterface, get_connection_status) diff --git a/UNITTESTS/features/netsocket/PPPInterface/unittest.cmake b/UNITTESTS/features/netsocket/PPPInterface/unittest.cmake index e2480c22d7..956803dfe3 100644 --- a/UNITTESTS/features/netsocket/PPPInterface/unittest.cmake +++ b/UNITTESTS/features/netsocket/PPPInterface/unittest.cmake @@ -32,8 +32,6 @@ set(unittest-test-sources stubs/mbed_shared_queues_stub.cpp stubs/nsapi_dns_stub.cpp stubs/EventFlags_stub.cpp - stubs/stoip4_stub.c - stubs/ip4tos_stub.c stubs/NetworkStack_stub.cpp stubs/NetworkInterfaceDefaults_stub.cpp stubs/SocketStats_Stub.cpp diff --git a/UNITTESTS/stubs/AT_CellularStack_stub.cpp b/UNITTESTS/stubs/AT_CellularStack_stub.cpp index 06843c49bd..f6187bd8d6 100644 --- a/UNITTESTS/stubs/AT_CellularStack_stub.cpp +++ b/UNITTESTS/stubs/AT_CellularStack_stub.cpp @@ -36,11 +36,6 @@ nsapi_error_t AT_CellularStack::get_ip_address(SocketAddress* address) return NSAPI_ERROR_UNSUPPORTED; } -const char *AT_CellularStack::get_ip_address() -{ - return NULL; -} - nsapi_error_t AT_CellularStack::socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto) { return NSAPI_ERROR_OK; diff --git a/UNITTESTS/stubs/OnboardNetworkStack_mock.h b/UNITTESTS/stubs/OnboardNetworkStack_mock.h index 57d5b506f3..24d15f5942 100644 --- a/UNITTESTS/stubs/OnboardNetworkStack_mock.h +++ b/UNITTESTS/stubs/OnboardNetworkStack_mock.h @@ -82,7 +82,6 @@ public: MOCK_CONST_METHOD0(get_connection_status, nsapi_connection_status_t()); MOCK_METHOD1(get_interface_name, char *(char *buf)); MOCK_METHOD2(get_mac_address, char *(char *buf, nsapi_size_t buflen)); - MOCK_METHOD2(get_ip_address, char *(char *buf, nsapi_size_t buflen)); MOCK_METHOD1(get_ip_address, nsapi_error_t (SocketAddress *address)); MOCK_METHOD1(get_ipv6_link_local_address, nsapi_error_t(SocketAddress *address)); MOCK_METHOD2(get_netmask, char *(char *buf, nsapi_size_t buflen));