Improved Raft event tracer - added event code to string conversion

This commit is contained in:
Pavel Kirienko
2015-05-08 17:14:12 +03:00
parent 1f7c0b40b3
commit dab32220e0
3 changed files with 73 additions and 3 deletions
@@ -57,9 +57,9 @@ class EventTracer : public uavcan::IDynamicNodeIDAllocationServerEventTracer
{
const std::string id_;
virtual void onEvent(uavcan::uint16_t event_code, uavcan::int64_t event_argument)
virtual void onEvent(uavcan::uint16_t code, uavcan::int64_t argument)
{
std::cout << "EVENT [" << id_ << "]\t" << event_code << "\t" << event_argument << std::endl;
std::cout << "EVENT [" << id_ << "]\t" << code << "\t" << getEventName(code) << "\t" << argument << std::endl;
}
public:
@@ -874,6 +874,23 @@ TEST(DynamicNodeIDAllocationServer, RaftCoreBasic)
}
TEST(DynamicNodeIDAllocationServer, EventCodeToString)
{
using uavcan::IDynamicNodeIDAllocationServerEventTracer;
using namespace uavcan::dynamic_node_id_server_impl;
// Simply checking some error codes
ASSERT_STREQ("Error",
IDynamicNodeIDAllocationServerEventTracer::getEventName(TraceError));
ASSERT_STREQ("RaftModeSwitch",
IDynamicNodeIDAllocationServerEventTracer::getEventName(TraceRaftModeSwitch));
ASSERT_STREQ("RaftAppendEntriesCallFailure",
IDynamicNodeIDAllocationServerEventTracer::getEventName(TraceRaftAppendEntriesCallFailure));
ASSERT_STREQ("DiscoveryReceived",
IDynamicNodeIDAllocationServerEventTracer::getEventName(TraceDiscoveryReceived));
}
TEST(DynamicNodeIDAllocationServer, ObjectSizes)
{
std::cout << "Log: " << sizeof(uavcan::dynamic_node_id_server_impl::Log) << std::endl;