Empty service client test (fails to compile due to a mistake in template instantiation)

This commit is contained in:
Pavel Kirienko
2015-04-21 21:46:33 +03:00
parent b6659f096f
commit 78e2351df5
+39
View File
@@ -10,6 +10,7 @@
#include <uavcan/protocol/RestartNode.hpp>
#include <uavcan/protocol/GetDataTypeInfo.hpp>
#include <root_ns_a/StringService.hpp>
#include <root_ns_a/EmptyService.hpp>
#include <queue>
#include "test_node.hpp"
@@ -52,6 +53,12 @@ static void stringServiceServerCallback(const uavcan::ReceivedDataStructure<root
rsp.string_response += req.string_request;
}
static void emptyServiceServerCallback(const uavcan::ReceivedDataStructure<root_ns_a::EmptyService::Request>&,
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<root_ns_a::EmptyService> _registrator;
// Server
uavcan::ServiceServer<root_ns_a::EmptyService> server(nodes.a);
ASSERT_EQ(0, server.start(emptyServiceServerCallback));
{
// Caller
typedef uavcan::ServiceClient<root_ns_a::EmptyService,
typename ServiceCallResultHandler<root_ns_a::EmptyService>::Binder > ClientType;
ServiceCallResultHandler<root_ns_a::EmptyService> 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;