diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/alltypes/encode_alltypes.c | 2 | ||||
-rw-r--r-- | tests/basic_buffer/decode_buffer.c | 2 | ||||
-rw-r--r-- | tests/basic_buffer/encode_buffer.c | 2 | ||||
-rw-r--r-- | tests/encode_unittests/encode_unittests.c | 13 |
4 files changed, 16 insertions, 3 deletions
diff --git a/tests/alltypes/encode_alltypes.c b/tests/alltypes/encode_alltypes.c index 88fc10f0..9a2c6f60 100644 --- a/tests/alltypes/encode_alltypes.c +++ b/tests/alltypes/encode_alltypes.c @@ -115,7 +115,7 @@ int main(int argc, char **argv) alltypes.end = 1099; { - uint8_t buffer[1024]; + uint8_t buffer[AllTypes_size]; pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); /* Now encode it and check if we succeeded. */ diff --git a/tests/basic_buffer/decode_buffer.c b/tests/basic_buffer/decode_buffer.c index d231c916..fae9e2fa 100644 --- a/tests/basic_buffer/decode_buffer.c +++ b/tests/basic_buffer/decode_buffer.c @@ -60,7 +60,7 @@ bool print_person(pb_istream_t *stream) int main() { - uint8_t buffer[512]; + uint8_t buffer[Person_size]; pb_istream_t stream; size_t count; diff --git a/tests/basic_buffer/encode_buffer.c b/tests/basic_buffer/encode_buffer.c index d3e4f6e6..c412c14e 100644 --- a/tests/basic_buffer/encode_buffer.c +++ b/tests/basic_buffer/encode_buffer.c @@ -10,7 +10,7 @@ int main() { - uint8_t buffer[512]; + uint8_t buffer[Person_size]; pb_ostream_t stream; /* Initialize the structure with constants */ diff --git a/tests/encode_unittests/encode_unittests.c b/tests/encode_unittests/encode_unittests.c index c3634ac8..32a37bf1 100644 --- a/tests/encode_unittests/encode_unittests.c +++ b/tests/encode_unittests/encode_unittests.c @@ -280,6 +280,19 @@ int main() TEST(!pb_encode(&s, CallbackContainerContainer_fields, &msg2)) } + { + uint8_t buffer[StringMessage_size]; + pb_ostream_t s; + StringMessage msg = {"0123456789"}; + + s = pb_ostream_from_buffer(buffer, sizeof(buffer)); + + COMMENT("Test that StringMessage_size is correct") + + TEST(pb_encode(&s, StringMessage_fields, &msg)); + TEST(s.bytes_written == StringMessage_size); + } + if (status != 0) fprintf(stdout, "\n\nSome tests FAILED!\n"); |