Merge pull request #170 from kylemanna/travis-ci
[apps/agl-service-can-low-level.git] / tests / basic_stream / decode_stream.c
index 2142977..798dcc5 100644 (file)
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <pb_decode.h>
 #include "person.pb.h"
+#include "test_helpers.h"
 
 /* This function is called once from main(), it handles
    the decoding and printing.
@@ -11,7 +12,7 @@
 bool print_person(pb_istream_t *stream)
 {
     int i;
-    Person person;
+    Person person = Person_init_zero;
     
     if (!pb_decode(stream, Person_fields, &person))
         return false;
@@ -69,10 +70,10 @@ bool callback(pb_istream_t *stream, uint8_t *buf, size_t count)
 
 int main()
 {
-    /* Maximum size is specified to prevent infinite length messages from
-     * hanging this in the fuzz test.
-     */
-    pb_istream_t stream = {&callback, stdin, 10000};
+    pb_istream_t stream = {&callback, NULL, SIZE_MAX};
+    stream.state = stdin;
+    SET_BINARY_MODE(stdin);
+
     if (!print_person(&stream))
     {
         printf("Parsing failed: %s\n", PB_GET_ERROR(&stream));