summaryrefslogtreecommitdiffstats
path: root/tests/missing_fields
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-04-09 19:39:12 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-04-09 19:39:12 +0300
commit1d249a48ea979729d1b818847dfbea3316cc527e (patch)
treeaeee8447a2d11476ccc2b2d654fb6bba45cd2ed5 /tests/missing_fields
parent3e83d81b09606791b05715e6680ea57e65f06234 (diff)
Fix bug in missing_fields test case
Diffstat (limited to 'tests/missing_fields')
-rw-r--r--tests/missing_fields/missing_fields.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/missing_fields/missing_fields.c b/tests/missing_fields/missing_fields.c
index b9a273a2..8aded827 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))
{