From b63e582bdb34b4727a8eb551fc72ee0476047a46 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Sat, 5 Apr 2014 11:26:39 +0300 Subject: Add a convenience function pb_get_encoded_size() There is minimal size penalty from this, and it is probably much more intuitive to use than PB_OSTREAM_SIZING itself. This has been suggested before also, but I ended up refusing it back them. Reconsidering it now, I see that an intuitive API is much better than any amount of documentation explaining a non-intuitive API. Update issue 16 Status: FixedInGit --- tests/encode_unittests/encode_unittests.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/encode_unittests') diff --git a/tests/encode_unittests/encode_unittests.c b/tests/encode_unittests/encode_unittests.c index edbc10a9..06935f9a 100644 --- a/tests/encode_unittests/encode_unittests.c +++ b/tests/encode_unittests/encode_unittests.c @@ -281,6 +281,15 @@ int main() TEST(WRITES(pb_encode_delimited(&s, IntegerContainer_fields, &msg), "\x09\x0A\x07\x0A\x05\x01\x02\x03\x04\x05")) } + + { + IntegerContainer msg = {{5, {1,2,3,4,5}}}; + size_t size; + + COMMENT("Test pb_get_encoded_size.") + TEST(pb_get_encoded_size(&size, IntegerContainer_fields, &msg) && + size == 9); + } { uint8_t buffer[10]; -- cgit 1.2.3-korg