diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-09-11 13:16:20 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-09-11 13:16:20 +0300 |
commit | b9f14bddf778a5ed27e3289b90a0657fec3e1a53 (patch) | |
tree | 972d67e547f1816d3dbe0643ea8add734ef8e90e /tests/callbacks/decode_callbacks.c | |
parent | e2e9980627810fe0ee2b8f119bcf651f0f318a8a (diff) |
Make all the tests ANSI C compatible.
Diffstat (limited to 'tests/callbacks/decode_callbacks.c')
-rw-r--r-- | tests/callbacks/decode_callbacks.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/callbacks/decode_callbacks.c b/tests/callbacks/decode_callbacks.c index b5056923..c8daed29 100644 --- a/tests/callbacks/decode_callbacks.c +++ b/tests/callbacks/decode_callbacks.c @@ -5,6 +5,7 @@ #include <stdio.h> #include <pb_decode.h> #include "callbacks.pb.h" +#include "test_helpers.h" bool print_string(pb_istream_t *stream, const pb_field_t *field, void **arg) { @@ -50,21 +51,24 @@ bool print_fixed64(pb_istream_t *stream, const pb_field_t *field, void **arg) if (!pb_decode_fixed64(stream, &value)) return false; - printf((char*)*arg, (long long)value); + printf((char*)*arg, (long)value); return true; } int main() { uint8_t buffer[1024]; - size_t length = fread(buffer, 1, 1024, stdin); - pb_istream_t stream = pb_istream_from_buffer(buffer, length); - + size_t length; + pb_istream_t stream; /* Note: empty initializer list initializes the struct with all-0. * This is recommended so that unused callbacks are set to NULL instead * of crashing at runtime. */ - TestMessage testmessage = {}; + TestMessage testmessage = {{{NULL}}}; + + SET_BINARY_MODE(stdin); + length = fread(buffer, 1, 1024, stdin); + stream = pb_istream_from_buffer(buffer, length); testmessage.submsg.stringvalue.funcs.decode = &print_string; testmessage.submsg.stringvalue.arg = "submsg {\n stringvalue: \"%s\"\n"; @@ -73,7 +77,7 @@ int main() testmessage.submsg.fixed32value.funcs.decode = &print_fixed32; testmessage.submsg.fixed32value.arg = " fixed32value: %ld\n"; testmessage.submsg.fixed64value.funcs.decode = &print_fixed64; - testmessage.submsg.fixed64value.arg = " fixed64value: %lld\n}\n"; + testmessage.submsg.fixed64value.arg = " fixed64value: %ld\n}\n"; testmessage.stringvalue.funcs.decode = &print_string; testmessage.stringvalue.arg = "stringvalue: \"%s\"\n"; |