27 #include <google/protobuf/descriptor.pb.h>
29 #include "../../binary.h"
30 #include "../../codec.h"
36 template <
typename TestMsg>
void decode_check(
const TestMsg& msg_in)
38 std::cout <<
"Message in:\n" << msg_in.DebugString() << std::endl;
40 std::cout <<
"Try encode (in bounds)..." << std::endl;
42 codec.encode(&bytes, msg_in);
43 std::cout <<
"... got bytes (hex): " <<
dccl::hex_encode(bytes) << std::endl;
45 std::cout <<
"Try decode..." << std::endl;
48 codec.decode(bytes, &msg_out);
50 std::cout <<
"... got Message out:\n" << msg_out.DebugString() << std::endl;
53 int main(
int ,
char* [])
55 dccl::dlog.
connect(dccl::logger::ALL, &std::cerr);
57 codec.load<TestMsgOmit1>();
58 codec.info<TestMsgOmit1>();
60 codec.load<TestMsgOmit2>();
61 codec.info<TestMsgOmit2>();
63 codec.load<TestMsgNormal>();
64 codec.info<TestMsgNormal>();
95 codec.encode(&bytes, msg_in);
96 TestMsgNormalId3 msg_out;
101 codec.decode(bytes, &msg_out);
105 std::cout <<
"Caught expected exception: " << e.what() << std::endl;
109 std::cout <<
"all tests passed" << std::endl;