27 #include "../../codec.h"
31 int main(
int ,
char* [])
33 dccl::dlog.
connect(dccl::logger::ALL, &std::cerr);
37 codec.load<NumericMsg>();
38 codec.info<NumericMsg>(&dccl::dlog);
42 codec.load<NegativeResolutionNumericMsg>();
43 bool message_should_fail_load =
false;
44 assert(message_should_fail_load);
49 <<
"** Note: this error is expected during proper execution of this unit test **: "
50 "Field a failed validation: (dccl.field).resolution must be greater than 0."
56 codec.load<BothResolutionAndPrecisionSetNumericMsg>();
57 bool message_should_fail_load =
false;
58 assert(message_should_fail_load);
62 std::cout <<
"** Note: this error is expected during proper execution of this unit test "
63 "**: Field a failed validation: at most one of either (dccl.field).precision "
64 "or (dccl.field).resolution can be set."
70 codec.load<TooBigNumericMsg>();
71 bool message_should_fail_load =
false;
72 assert(message_should_fail_load);
76 std::cout <<
"** Note: this error is expected during proper execution of this unit test "
77 "**: Field a failed validation: "
78 "[(dccl.field).max-(dccl.field).min]/(dccl.field).resolution must fit in a "
79 "double-precision floating point value. Please increase min, decrease max, or "
86 codec.load<MinNotMultipleOfResolution>();
87 bool message_should_fail_load =
false;
88 assert(message_should_fail_load);
92 std::cout <<
"** Note: this error is expected during proper execution of this unit test "
93 "**: Field a failed validation: (dccl.field).min must be an exact multiple of "
94 "(dccl.field).resolution."
100 codec.load<MaxNotMultipleOfResolution>();
101 bool message_should_fail_load =
false;
102 assert(message_should_fail_load);
106 std::cout <<
"** Note: this error is expected during proper execution of this unit test "
107 "**: Field a failed validation: (dccl.field).max must be an exact multiple of "
108 "(dccl.field).resolution."
114 msg_in.set_a(10.12345678);
115 msg_in.set_b(11.42106);
116 msg_in.set_u1(18446744073709500000ull);
121 msg_in.set_u6(25500);
124 codec.encode(&encoded, msg_in);
127 codec.decode(encoded, &msg_out);
129 msg_in.set_b(11.4211);
133 assert(msg_in.SerializeAsString() == msg_out.SerializeAsString());
135 std::cout <<
"all tests passed" << std::endl;