12 COMMENT(
"Test inline byte fields");
15 Message1 msg1 = Message1_init_zero;
16 TEST(
sizeof(msg1.data) == 32);
20 Message1 msg1 = Message1_init_zero;
23 Message1 msg1_deserialized = Message1_init_zero;
26 for (i = 0; i < 32; i++) {
31 TEST(ostream.bytes_written == Message1_size);
33 TEST(
pb_decode(&istream, Message1_fields, &msg1_deserialized));
35 TEST(istream.bytes_left == 0);
36 TEST(
memcmp(&msg1_deserialized, &msg1,
sizeof(msg1)) == 0);
40 Message2 msg2 = {
true, {0}};
41 Message2 msg2_no_data = {
false, {1}};
44 Message2 msg2_deserialized = Message2_init_zero;
47 for (i = 0; i < 64; i++) {
52 TEST(ostream.bytes_written == Message2_size);
54 TEST(
pb_decode(&istream, Message2_fields, &msg2_deserialized));
56 TEST(istream.bytes_left == 0);
57 TEST(
memcmp(&msg2_deserialized, &msg2,
sizeof(msg2)) == 0);
58 TEST(msg2_deserialized.has_data);
60 memset(msg2_buffer, 0,
sizeof(msg2_buffer));
64 TEST(
pb_decode(&istream, Message2_fields, &msg2_deserialized));
65 TEST(!msg2_deserialized.has_data);
66 TEST(
memcmp(&msg2_deserialized, &msg2,
sizeof(msg2)) != 0);
70 fprintf(
stdout,
"\n\nSome tests FAILED!\n");