27#include "../../codec.h"
31int main(
int argc,
char* argv[])
34 for (
int i = 1; i < argc; ++i)
36 if (argv[i] && argv[i][0] ==
'-' && argv[i][1] ==
'v' && argv[i][2] ==
'\0')
40 dccl::dlog.
connect(verbose ? dccl::logger::ALL :
dccl::logger::WARN_PLUS, &std::cerr);
44 codec.load<NumericMsg>();
45 codec.info<NumericMsg>(&dccl::dlog);
49 codec.load<NegativeResolutionNumericMsg>();
50 bool message_should_fail_load =
false;
51 assert(message_should_fail_load);
55 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog
56 <<
"** Note: this error is expected during proper execution of this unit test **: "
57 "Field a failed validation: (dccl.field).resolution must be greater than 0."
63 codec.load<BothResolutionAndPrecisionSetNumericMsg>();
64 bool message_should_fail_load =
false;
65 assert(message_should_fail_load);
69 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"** Note: this error is expected during proper execution of this unit test "
70 "**: Field a failed validation: at most one of either (dccl.field).precision "
71 "or (dccl.field).resolution can be set."
77 codec.load<TooBigNumericMsg>();
78 bool message_should_fail_load =
false;
79 assert(message_should_fail_load);
83 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"** Note: this error is expected during proper execution of this unit test "
84 "**: Field a failed validation: "
85 "[(dccl.field).max-(dccl.field).min]/(dccl.field).resolution must fit in a "
86 "double-precision floating point value. Please increase min, decrease max, or "
93 codec.load<MinNotMultipleOfResolution>();
94 bool message_should_fail_load =
false;
95 assert(message_should_fail_load);
99 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"** Note: this error is expected during proper execution of this unit test "
100 "**: Field a failed validation: (dccl.field).min must be an exact multiple of "
101 "(dccl.field).resolution."
107 codec.load<MaxNotMultipleOfResolution>();
108 bool message_should_fail_load =
false;
109 assert(message_should_fail_load);
113 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"** Note: this error is expected during proper execution of this unit test "
114 "**: Field a failed validation: (dccl.field).max must be an exact multiple of "
115 "(dccl.field).resolution."
121 msg_in.set_a(10.12345678);
122 msg_in.set_b(11.42106);
123 msg_in.set_u1(18446744073709500000ull);
128 msg_in.set_u6(25500);
131 codec.encode(&encoded, msg_in);
134 codec.decode(encoded, &msg_out);
136 msg_in.set_b(11.4211);
140 assert(msg_in.SerializeAsString() == msg_out.SerializeAsString());
142 dccl::dlog.
is(dccl::logger::INFO) && dccl::dlog <<
"all tests passed" << std::endl;
The Dynamic CCL enCODer/DECoder. This is the main class you will use to load, encode and decode DCCL ...
Exception class for DCCL.
bool is(logger::Verbosity verbosity, logger::Group group=logger::GENERAL)
Indicates the verbosity of the Logger until the next std::flush or std::endl. The boolean return is u...
void connect(int verbosity_mask, Slot slot)
Connect the output of one or more given verbosities to a slot (function pointer or similar)
Dynamic Compact Control Language namespace.