mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-09 17:08:52 +08:00
Empty service client test (fails to compile due to a mistake in template instantiation)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user