From 1d249a48ea979729d1b818847dfbea3316cc527e Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Wed, 9 Apr 2014 19:39:12 +0300 Subject: Fix bug in missing_fields test case --- tests/missing_fields/missing_fields.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'tests/missing_fields') diff --git a/tests/missing_fields/missing_fields.c b/tests/missing_fields/missing_fields.c index b9a273a..8aded82 100644 --- a/tests/missing_fields/missing_fields.c +++ b/tests/missing_fields/missing_fields.c @@ -8,6 +8,7 @@ int main() { uint8_t buffer[512]; + size_t size; /* Create a message with one missing field */ { @@ -19,12 +20,14 @@ int main() printf("Encode failed.\n"); return 1; } + + size = stream.bytes_written; } /* Test that it decodes properly if we don't require that field */ { MissingField msg = {0}; - pb_istream_t stream = pb_istream_from_buffer(buffer, sizeof(buffer)); + pb_istream_t stream = pb_istream_from_buffer(buffer, size); if (!pb_decode(&stream, MissingField_fields, &msg)) { @@ -36,7 +39,7 @@ int main() /* Test that it does *not* decode properly if we require the field */ { AllFields msg = {0}; - pb_istream_t stream = pb_istream_from_buffer(buffer, sizeof(buffer)); + pb_istream_t stream = pb_istream_from_buffer(buffer, size); if (pb_decode(&stream, AllFields_fields, &msg)) { -- cgit 1.2.3-korg