From bb985e99274b537ee662d630b02664a3825d8829 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Sat, 6 Jul 2013 16:16:00 +0300 Subject: Add pb_decode_delimited and pb_encode_delimited wrapper functions. Update issue 74 Status: FixedInGit --- tests/decode_unittests.c | 10 ++++++++++ tests/encode_unittests.c | 10 ++++++++++ 2 files changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/decode_unittests.c b/tests/decode_unittests.c index 1e74c34d..6ad05f00 100644 --- a/tests/decode_unittests.c +++ b/tests/decode_unittests.c @@ -289,6 +289,16 @@ int main() TEST((s = S("\x08"), !pb_decode(&s, IntegerArray_fields, &dest))) } + { + pb_istream_t s; + IntegerContainer dest = {}; + + COMMENT("Testing pb_decode_delimited") + TEST((s = S("\x09\x0A\x07\x0A\x05\x01\x02\x03\x04\x05"), + pb_decode_delimited(&s, IntegerContainer_fields, &dest)) && + dest.submsg.data_count == 5) + } + if (status != 0) fprintf(stdout, "\n\nSome tests FAILED!\n"); diff --git a/tests/encode_unittests.c b/tests/encode_unittests.c index 6a8f5e9e..c3634ac8 100644 --- a/tests/encode_unittests.c +++ b/tests/encode_unittests.c @@ -244,6 +244,16 @@ int main() "\x0A\x07\x0A\x05\x01\x02\x03\x04\x05")) } + { + uint8_t buffer[20]; + pb_ostream_t s; + IntegerContainer msg = {{5, {1,2,3,4,5}}}; + + COMMENT("Test pb_encode_delimited.") + TEST(WRITES(pb_encode_delimited(&s, IntegerContainer_fields, &msg), + "\x09\x0A\x07\x0A\x05\x01\x02\x03\x04\x05")) + } + { uint8_t buffer[10]; pb_ostream_t s; -- cgit 1.2.3-korg