26#include "../../codec.h"
32#include "../../binary.h"
35template <
typename Message>
void run_test(
dccl::Codec& codec, Message& msg_in)
37 std::cout <<
"Try encode..." << std::endl;
39 codec.encode(&bytes, msg_in);
40 std::cout <<
"... got bytes (hex): " <<
dccl::hex_encode(bytes) << std::endl;
42 std::cout <<
"Try decode..." << std::endl;
44 auto msg_out = codec.decode<std::unique_ptr<google::protobuf::Message>>(bytes);
45 std::cout <<
"... got Message out:\n" << msg_out->DebugString() << std::endl;
46 assert(msg_in.SerializeAsString() == msg_out->SerializeAsString());
49int main(
int ,
char* [])
51 dccl::dlog.
connect(dccl::logger::ALL, &std::cerr);
54 codec.load_library(
"libtest_autoload" SHARED_LIBRARY_SUFFIX);
56 codec.info_all(&std::cout);
60 run_test(codec, msg_in1);
64 run_test(codec, msg_in2);
68 run_test(codec, msg_in3);
70 TestMessage3SupersetName msg_in4;
72 run_test(codec, msg_in4);
74 std::cout <<
"all tests passed" << std::endl;
The Dynamic CCL enCODer/DECoder. This is the main class you will use to load, encode and decode DCCL ...
void connect(int verbosity_mask, Slot slot)
Connect the output of one or more given verbosities to a slot (function pointer or similar)
void hex_encode(CharIterator begin, CharIterator end, std::string *out, bool upper_case=false)
Encodes a (little-endian) hexadecimal string from a byte string. Index 0 of begin is written to index...