YAML streaming for generated types

This commit is contained in:
Pavel Kirienko
2014-03-07 00:43:36 +04:00
parent da6e25a708
commit 4753d4ac79
10 changed files with 386 additions and 5 deletions
@@ -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());
}