From e83fbd18d3fa33af8a57198cddefe5fcef1b2f58 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Sun, 20 Oct 2013 21:42:00 +0300 Subject: Check array max size when encoding. Update issue 90 Status: FixedInGit --- tests/encode_unittests/encode_unittests.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests') 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 @@ -223,6 +223,20 @@ int main() TEST(!pb_encode(&s, FloatArray_fields, &msg)) } + { + 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; -- cgit