From 78e2351df5f3c2e13f32736ebbe64c7405ee8522 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Tue, 21 Apr 2015 21:46:33 +0300 Subject: [PATCH] Empty service client test (fails to compile due to a mistake in template instantiation) --- libuavcan/test/node/service_client.cpp | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) 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;