1 #include "pb_encode.h"
2 #include "pb_decode.h"
3
4 #include "test.h"
5
6 #include "pio_with_options.pb.h"
7
main(int argc,char * argv[])8 int main(int argc, char *argv[]) {
9
10 int status = 0;
11
12 uint8_t buffer[256];
13 pb_ostream_t ostream;
14 pb_istream_t istream;
15 size_t written;
16
17 TestMessageWithOptions original = TestMessageWithOptions_init_zero;
18 strcpy(original.str,"Hello");
19
20 ostream = pb_ostream_from_buffer(buffer, sizeof(buffer));
21
22 TEST(pb_encode(&ostream, &TestMessageWithOptions_msg, &original));
23
24 written = ostream.bytes_written;
25
26 istream = pb_istream_from_buffer(buffer, written);
27
28 TestMessageWithOptions decoded = TestMessageWithOptions_init_zero;
29
30 TEST(pb_decode(&istream, &TestMessageWithOptions_msg, &decoded));
31
32 TEST(strcmp(decoded.str,"Hello") == 0);
33
34 return status;
35 }
36