summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-10-20 21:42:00 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2013-10-20 21:42:00 +0300
commite83fbd18d3fa33af8a57198cddefe5fcef1b2f58 (patch)
treedcb35036e79df9e2828b51e9158544ad793098c1 /tests
parent388d4de833cf4e2127b2ab0489cb6b14ecc0cbb5 (diff)
Check array max size when encoding.
Update issue 90 Status: FixedInGit
Diffstat (limited to 'tests')
-rw-r--r--tests/encode_unittests/encode_unittests.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/encode_unittests/encode_unittests.c b/tests/encode_unittests/encode_unittests.c
index 32a37bf1..14bc62ee 100644
--- a/tests/encode_unittests/encode_unittests.c
+++ b/tests/encode_unittests/encode_unittests.c
@@ -224,6 +224,20 @@ int main()
}
{
+ uint8_t buffer[50];
+ pb_ostream_t s;
+ FloatArray msg = {1, {99.0f}};
+
+ COMMENT("Test array size limit in pb_encode")
+
+ s = pb_ostream_from_buffer(buffer, sizeof(buffer));
+ TEST((msg.data_count = 10) && pb_encode(&s, FloatArray_fields, &msg))
+
+ s = pb_ostream_from_buffer(buffer, sizeof(buffer));
+ TEST((msg.data_count = 11) && !pb_encode(&s, FloatArray_fields, &msg))
+ }
+
+ {
uint8_t buffer[10];
pb_ostream_t s;
CallbackArray msg;