Encoder
[apps/agl-service-can-low-level.git] / tests / test_encode1.c
1 #include <stdio.h>
2 #include <pb_encode.h>
3 #include "person.h"
4
5 /* This test has only one source file anyway.. */
6 #include "person.c"
7
8 bool callback(pb_ostream_t *stream, const uint8_t *buf, size_t count)
9 {
10     return fwrite(buf, 1, count, stdout) == count;
11 }
12
13 int main()
14 {
15     Person person = {"Test Person 99", 99, true, "test@person.com",
16         1, {{"555-12345678", true, Person_PhoneType_MOBILE}}};
17     
18     pb_ostream_t stream = {&callback, 0, SIZE_MAX, 0};
19     
20     pb_encode(&stream, Person_fields, &person);
21     
22     return 0;
23 }