mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 07:11:36 +08:00
YAML streaming for generated types
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <uavcan/Timestamp.hpp>
|
||||
#include <uavcan/FigureOfMerit.hpp>
|
||||
#include <uavcan/mavlink/Message.hpp>
|
||||
@@ -29,3 +30,92 @@
|
||||
#include <uavcan/protocol/file/BeginTransfer.hpp>
|
||||
#include <uavcan/protocol/file/Crc.hpp>
|
||||
#include <uavcan/protocol/file/GetInfo.hpp>
|
||||
|
||||
#include <root_ns_a/Deep.hpp>
|
||||
|
||||
|
||||
TEST(Dsdl, Streaming)
|
||||
{
|
||||
std::ostringstream os;
|
||||
|
||||
uavcan::mavlink::Message mavlink;
|
||||
os << mavlink << std::endl << "==========" << std::endl;
|
||||
|
||||
mavlink.compid = 12;
|
||||
mavlink.seq = 42;
|
||||
mavlink.payload = "Here goes payload";
|
||||
os << mavlink << std::endl << "==========" << std::endl;
|
||||
|
||||
uavcan::protocol::GetNodeInfo::Response get_node_info_rsp;
|
||||
os << get_node_info_rsp << std::endl << "==========" << std::endl;
|
||||
|
||||
root_ns_a::Deep ps;
|
||||
ps.a.resize(2);
|
||||
os << ps << std::endl << "==========" << std::endl;
|
||||
|
||||
static const std::string Reference = "seq: 0\n"
|
||||
"sysid: 0\n"
|
||||
"compid: 0\n"
|
||||
"msgid: 0\n"
|
||||
"payload: \"\"\n"
|
||||
"==========\n"
|
||||
"seq: 42\n"
|
||||
"sysid: 0\n"
|
||||
"compid: 12\n"
|
||||
"msgid: 0\n"
|
||||
"payload: \"Here goes payload\"\n"
|
||||
"==========\n"
|
||||
"software_version: \n"
|
||||
" major: 0\n"
|
||||
" minor: 0\n"
|
||||
"hardware_version: \n"
|
||||
" major: 0\n"
|
||||
" minor: 0\n"
|
||||
"uavcan_version: \n"
|
||||
" major: 0\n"
|
||||
" minor: 0\n"
|
||||
"status: \n"
|
||||
" uptime_sec: 0\n"
|
||||
" status_code: 0\n"
|
||||
"name: \"\"\n"
|
||||
"==========\n"
|
||||
"c: 0\n"
|
||||
"str: \"\"\n"
|
||||
"a: \n"
|
||||
" - \n"
|
||||
" scalar: 0\n"
|
||||
" vector: \n"
|
||||
" - \n"
|
||||
" vector: [0, 0, 0, 0]\n"
|
||||
" bools: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
|
||||
" - \n"
|
||||
" vector: [0, 0, 0, 0]\n"
|
||||
" bools: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
|
||||
" - \n"
|
||||
" vector: [0, 0, 0, 0]\n"
|
||||
" bools: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
|
||||
" - \n"
|
||||
" scalar: 0\n"
|
||||
" vector: \n"
|
||||
" - \n"
|
||||
" vector: [0, 0, 0, 0]\n"
|
||||
" bools: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
|
||||
" - \n"
|
||||
" vector: [0, 0, 0, 0]\n"
|
||||
" bools: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
|
||||
" - \n"
|
||||
" vector: [0, 0, 0, 0]\n"
|
||||
" bools: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
|
||||
"b: \n"
|
||||
" - \n"
|
||||
" vector: [0, 0, 0, 0]\n"
|
||||
" bools: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
|
||||
" - \n"
|
||||
" vector: [0, 0, 0, 0]\n"
|
||||
" bools: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
|
||||
" - \n"
|
||||
" vector: [0, 0, 0, 0]\n"
|
||||
" bools: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"
|
||||
"==========\n";
|
||||
ASSERT_EQ(Reference, os.str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user