Windows build fixes
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include "alltypes.pb.h"
|
#include "alltypes.pb.h"
|
||||||
|
#include "test_helpers.h"
|
||||||
|
|
||||||
#define TEST(x) if (!(x)) { \
|
#define TEST(x) if (!(x)) { \
|
||||||
printf("Test " #x " failed.\n"); \
|
printf("Test " #x " failed.\n"); \
|
||||||
@@ -176,15 +177,19 @@ bool check_alltypes(pb_istream_t *stream, int mode)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
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. */
|
/* Whether to expect the optional values or the default values. */
|
||||||
int mode = (argc > 1) ? atoi(argv[1]) : 0;
|
int mode = (argc > 1) ? atoi(argv[1]) : 0;
|
||||||
|
|
||||||
/* Read the data into buffer */
|
/* Read the data into buffer */
|
||||||
uint8_t buffer[1024];
|
SET_BINARY_MODE(stdin);
|
||||||
size_t count = fread(buffer, 1, sizeof(buffer), stdin);
|
count = fread(buffer, 1, sizeof(buffer), stdin);
|
||||||
|
|
||||||
/* Construct a pb_istream_t for reading from the buffer */
|
/* 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 */
|
/* Decode and print out the stuff */
|
||||||
if (!check_alltypes(&stream, mode))
|
if (!check_alltypes(&stream, mode))
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
#include "alltypes.pb.h"
|
#include "alltypes.pb.h"
|
||||||
|
#include "test_helpers.h"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -120,6 +121,7 @@ int main(int argc, char **argv)
|
|||||||
/* Now encode it and check if we succeeded. */
|
/* Now encode it and check if we succeeded. */
|
||||||
if (pb_encode(&stream, AllTypes_fields, &alltypes))
|
if (pb_encode(&stream, AllTypes_fields, &alltypes))
|
||||||
{
|
{
|
||||||
|
SET_BINARY_MODE(stdout);
|
||||||
fwrite(buffer, 1, stream.bytes_written, stdout);
|
fwrite(buffer, 1, stream.bytes_written, stdout);
|
||||||
return 0; /* Success */
|
return 0; /* Success */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ int main()
|
|||||||
testmessage.fixed32value.funcs.decode = &print_fixed32;
|
testmessage.fixed32value.funcs.decode = &print_fixed32;
|
||||||
testmessage.fixed32value.arg = "fixed32value: %ld\n";
|
testmessage.fixed32value.arg = "fixed32value: %ld\n";
|
||||||
testmessage.fixed64value.funcs.decode = &print_fixed64;
|
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.funcs.decode = &print_string;
|
||||||
testmessage.repeatedstring.arg = "repeatedstring: \"%s\"\n";
|
testmessage.repeatedstring.arg = "repeatedstring: \"%s\"\n";
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ incpath.Append(PROTOCPATH = '#alltypes')
|
|||||||
incpath.Append(CPPPATH = '#alltypes')
|
incpath.Append(CPPPATH = '#alltypes')
|
||||||
|
|
||||||
incpath.NanopbProto("extensions")
|
incpath.NanopbProto("extensions")
|
||||||
enc = incpath.Program(["encode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb.o", "#common/pb_encode.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.o", "#common/pb_decode.o"])
|
dec = incpath.Program(["decode_extensions.c", "extensions.pb.c", "#alltypes/alltypes.pb$OBJSUFFIX", "#common/pb_decode.o"])
|
||||||
|
|
||||||
env.RunTest(enc)
|
env.RunTest(enc)
|
||||||
env.RunTest([dec, "encode_extensions.output"])
|
env.RunTest([dec, "encode_extensions.output"])
|
||||||
|
|||||||
Reference in New Issue
Block a user