#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"); \
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))
#include <string.h>
#include <pb_encode.h>
#include "alltypes.pb.h"
+#include "test_helpers.h"
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 */
}
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";
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"])