18 memset(&msg, 0xAA,
sizeof(msg));
20 if (!
pb_decode(stream, OneOfMessage_fields, &msg))
27 TEST(msg.prefix == 123);
28 TEST(msg.suffix == 321);
33 TEST(msg.which_values == OneOfMessage_first_tag);
34 TEST(msg.values.first == 999);
38 TEST(msg.which_values == OneOfMessage_second_tag);
43 TEST(msg.which_values == OneOfMessage_third_tag);
44 TEST(msg.values.third.array[0] == 1);
45 TEST(msg.values.third.array[1] == 2);
46 TEST(msg.values.third.array[2] == 3);
47 TEST(msg.values.third.array[3] == 4);
48 TEST(msg.values.third.array[4] == 5);
58 PlainOneOfMessage msg = PlainOneOfMessage_init_zero;
61 if (!
pb_decode(stream, PlainOneOfMessage_fields, &msg))
70 TEST(msg.which_values == OneOfMessage_first_tag);
71 TEST(msg.values.first == 999);
75 TEST(msg.which_values == OneOfMessage_second_tag);
80 TEST(msg.which_values == OneOfMessage_third_tag);
81 TEST(msg.values.third.array[0] == 1);
82 TEST(msg.values.third.array[1] == 2);
83 TEST(msg.values.third.array[2] == 3);
84 TEST(msg.values.third.array[3] == 4);
85 TEST(msg.values.third.array[4] == 5);
99 fprintf(
stderr,
"Usage: decode_oneof [number]\n");
109 printf(
"Message does not fit in buffer\n");
int test_oneof_1(pb_istream_t *stream, int option)
MOSAPI s32 strcmp(const char *str1, const char *str2)
size_t fread(void *__restrict ptr, size_t size, size_t nmemb, FILE *__restrict stream)
MOSAPI s32 atoi(const char *nptr)
int test_oneof_2(pb_istream_t *stream, int option)
#define PB_GET_ERROR(stream)
bool pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields, void *dest_struct)
pb_istream_t pb_istream_from_buffer(const pb_byte_t *buf, size_t msglen)
static void * memset(void *s, int c, size_t n)
#define SET_BINARY_MODE(file)