21 msg->static_req_submsg.dynamic_str =
"12345";
22 msg->static_req_submsg.dynamic_str_arr_count = 3;
24 msg->static_req_submsg.dynamic_submsg_count = 2;
26 msg->static_req_submsg.dynamic_submsg[1].dynamic_str =
"abc";
27 msg->static_opt_submsg.dynamic_str =
"abc";
28 msg->static_rep_submsg_count = 2;
29 msg->static_rep_submsg[1].dynamic_str =
"abc";
30 msg->has_static_opt_submsg =
true;
31 msg->dynamic_submsg = &msg->static_req_submsg;
33 msg->extensions = &
ext1;
34 ext1.type = &dynamic_ext;
35 ext1.dest = &msg->static_req_submsg;
37 ext2.type = &static_ext;
38 ext2.dest = &msg->static_req_submsg;
50 TestMessage msg = TestMessage_init_zero;
56 if (!
pb_encode(&stream, TestMessage_fields, &msg))
61 msgsize = stream.bytes_written;
70 TestMessage msg = TestMessage_init_zero;
74 msg.extensions = &
ext1;
75 ext1.type = &dynamic_ext;
78 ext2.type = &static_ext;
79 ext2.dest = &ext2_dest;
83 if (!
pb_decode(&stream, TestMessage_fields, &msg))
94 TEST(ostream.bytes_written == msgsize);
124 OneofMessage msg = OneofMessage_init_zero;
125 msg.which_msgs = OneofMessage_msg1_tag;
129 if (!
pb_encode(&stream, OneofMessage_fields, &msg))
138 OneofMessage msg = OneofMessage_init_zero;
140 msg.which_msgs = OneofMessage_msg2_tag;
143 msg.msgs.msg2.dynamic_str =
"ABCD";
144 msg.msgs.msg2.dynamic_str_arr_count = 1;
145 msg.msgs.msg2.dynamic_str_arr = &teststr;
148 if (!
pb_encode(&stream, OneofMessage_fields, &msg))
157 OneofMessage msg = OneofMessage_init_zero;
159 msg.which_msgs = OneofMessage_msg2_tag;
162 msg.msgs.msg2.dynamic_str =
"EFGH";
163 msg.msgs.msg2.dynamic_str_arr_count = 1;
164 msg.msgs.msg2.dynamic_str_arr = &teststr;
167 if (!
pb_encode(&stream, OneofMessage_fields, &msg))
173 msgsize = stream.bytes_written;
177 OneofMessage msg = OneofMessage_init_zero;
179 if (!
pb_decode(&stream, OneofMessage_fields, &msg))
185 TEST(msg.first == 99);
186 TEST(msg.which_msgs == OneofMessage_msg2_tag);
187 TEST(msg.msgs.msg2.dynamic_str);
188 TEST(
strcmp(msg.msgs.msg2.dynamic_str,
"EFGH") == 0);
189 TEST(msg.msgs.msg2.dynamic_str_arr !=
NULL);
190 TEST(msg.msgs.msg2.dynamic_str_arr_count == 2);
191 TEST(
strcmp(msg.msgs.msg2.dynamic_str_arr[0],
"1") == 0);
192 TEST(
strcmp(msg.msgs.msg2.dynamic_str_arr[1],
"2") == 0);
193 TEST(msg.msgs.msg2.dynamic_submsg ==
NULL);
194 TEST(msg.last == 88);
214 const size_t msgsize =
sizeof(
buffer);
217 OneofMessage msg = OneofMessage_init_zero;
223 TestMessage msg = TestMessage_init_zero;
229 RepeatedMessage msg = RepeatedMessage_init_zero;
size_t fwrite(const void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream)