summaryrefslogtreecommitdiffstats
path: root/tests/backwards_compatibility/decode_legacy.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-12-21 18:08:04 +0200
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-12-21 18:08:04 +0200
commited93db08dc19290ac3232abd1e7480c3d18c84a5 (patch)
tree391df74e06f89eabe50677423d1c602f6d91f4eb /tests/backwards_compatibility/decode_legacy.c
parentcd9004089fd4ae42cc68fd15f085f42c48494cb4 (diff)
Fix problem with decode_legacy test case on Windows.
Diffstat (limited to 'tests/backwards_compatibility/decode_legacy.c')
-rw-r--r--tests/backwards_compatibility/decode_legacy.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/backwards_compatibility/decode_legacy.c b/tests/backwards_compatibility/decode_legacy.c
index 315b16ef..9dfe437a 100644
--- a/tests/backwards_compatibility/decode_legacy.c
+++ b/tests/backwards_compatibility/decode_legacy.c
@@ -11,6 +11,7 @@
#include <stdlib.h>
#include <pb_decode.h>
#include "alltypes_legacy.h"
+#include "test_helpers.h"
#define TEST(x) if (!(x)) { \
printf("Test " #x " failed.\n"); \
@@ -176,15 +177,19 @@ bool check_alltypes(pb_istream_t *stream, int mode)
int main(int argc, char **argv)
{
+ uint8_t buffer[1024];
+ size_t count;
+ pb_istream_t stream;
+
/* Whether to expect the optional values or the default values. */
int mode = (argc > 1) ? atoi(argv[1]) : 0;
/* Read the data into buffer */
- uint8_t buffer[1024];
- size_t count = fread(buffer, 1, sizeof(buffer), stdin);
+ SET_BINARY_MODE(stdin);
+ count = fread(buffer, 1, sizeof(buffer), stdin);
/* Construct a pb_istream_t for reading from the buffer */
- pb_istream_t stream = pb_istream_from_buffer(buffer, count);
+ stream = pb_istream_from_buffer(buffer, count);
/* Decode and print out the stuff */
if (!check_alltypes(&stream, mode))