summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-09-11 13:42:56 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-09-11 13:42:56 +0300
commitd395768c8d3e63125c15950434fa255fb8c57717 (patch)
tree2f6994c7f3f9484ee4f173bfb52adde6c1a8253d /tests
parentb9f14bddf778a5ed27e3289b90a0657fec3e1a53 (diff)
Windows build fixes
Diffstat (limited to 'tests')
-rw-r--r--tests/alltypes/decode_alltypes.c11
-rw-r--r--tests/alltypes/encode_alltypes.c2
-rw-r--r--tests/callbacks/decode_callbacks.c2
-rw-r--r--tests/extensions/SConscript4
4 files changed, 13 insertions, 6 deletions
diff --git a/tests/alltypes/decode_alltypes.c b/tests/alltypes/decode_alltypes.c
index 55d025c0..ee2e115c 100644
--- a/tests/alltypes/decode_alltypes.c
+++ b/tests/alltypes/decode_alltypes.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <pb_decode.h>
#include "alltypes.pb.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))
diff --git a/tests/alltypes/encode_alltypes.c b/tests/alltypes/encode_alltypes.c
index 802e1574..88fc10f0 100644
--- a/tests/alltypes/encode_alltypes.c
+++ b/tests/alltypes/encode_alltypes.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <pb_encode.h>
#include "alltypes.pb.h"
+#include "test_helpers.h"
int main(int argc, char **argv)
{
@@ -120,6 +121,7 @@ int main(int argc, char **argv)
/* Now encode it and check if we succeeded. */
if (pb_encode(&stream, AllTypes_fields, &alltypes))
{
+ SET_BINARY_MODE(stdout);
fwrite(buffer, 1, stream.bytes_written, stdout);
return 0; /* Success */
}
diff --git a/tests/callbacks/decode_callbacks.c b/tests/callbacks/decode_callbacks.c
index c8daed29..45724d0b 100644
--- a/tests/callbacks/decode_callbacks.c
+++ b/tests/callbacks/decode_callbacks.c
@@ -86,7 +86,7 @@ int main()
testmessage.fixed32value.funcs.decode = &print_fixed32;
testmessage.fixed32value.arg = "fixed32value: %ld\n";
testmessage.fixed64value.funcs.decode = &print_fixed64;
- testmessage.fixed64value.arg = "fixed64value: %lld\n";
+ testmessage.fixed64value.arg = "fixed64value: %ld\n";
testmessage.repeatedstring.funcs.decode = &print_string;
testmessage.repeatedstring.arg = "repeatedstring: \"%s\"\n";
diff --git a/tests/extensions/SConscript b/tests/extensions/SConscript
index b48d6a66..f632a9ae 100644
--- a/tests/extensions/SConscript
+++ b/tests/extensions/SConscript
@@ -8,8 +8,8 @@ incpath.Append(PROTOCPATH = '#alltypes')
incpath.Append(CPPPATH = '#alltypes')
incpath.NanopbProto("extensions")
-enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb.o", "#common/pb_encode.o"])
-dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb.o", "#common/pb_decode.o"])
+enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb$OBJSUFFIX", "#common/pb_encode.o"])
+dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb$OBJSUFFIX", "#common/pb_decode.o"])
env.RunTest(enc)
env.RunTest([dec, "encode_extensions.output"])