diff --git a/libuavcan/test/node/service_client.cpp b/libuavcan/test/node/service_client.cpp index e6a390f2c3..4192bc890c 100644 --- a/libuavcan/test/node/service_client.cpp +++ b/libuavcan/test/node/service_client.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "test_node.hpp" @@ -52,6 +53,12 @@ static void stringServiceServerCallback(const uavcan::ReceivedDataStructure&, + root_ns_a::EmptyService::Response&) +{ + // Nothing to do - the service is empty +} + TEST(ServiceClient, Basic) { @@ -132,6 +139,38 @@ TEST(ServiceClient, Basic) } +TEST(ServiceClient, Empty) +{ + InterlinkedTestNodesWithSysClock nodes; + + // Type registration + uavcan::GlobalDataTypeRegistry::instance().reset(); + uavcan::DefaultDataTypeRegistrator _registrator; + + // Server + uavcan::ServiceServer server(nodes.a); + ASSERT_EQ(0, server.start(emptyServiceServerCallback)); + + { + // Caller + typedef uavcan::ServiceClient::Binder > ClientType; + ServiceCallResultHandler handler; + + ClientType client(nodes.b); + + client.setCallback(handler.bind()); + + root_ns_a::EmptyService::Request request; + + ASSERT_LT(0, client.call(1, request)); // OK + } + + // All destroyed - nobody listening + ASSERT_EQ(0, nodes.b.getDispatcher().getNumServiceResponseListeners()); +} + + TEST(ServiceClient, Sizes) { using namespace uavcan;