X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=tests%2Fdecode_unittests.c;h=6ad05f0092f1cf802f216627200743ec4ae4c961;hb=d7f3a74388b4825d2c980c53d0a740ddfd0e4770;hp=6ba6d4f2eff19952307ef4cf21853ca2a4197484;hpb=113bd7ee878ac2284c8c049fdb8dc2d2bd19f016;p=apps%2Fagl-service-can-low-level.git diff --git a/tests/decode_unittests.c b/tests/decode_unittests.c index 6ba6d4f2..6ad05f00 100644 --- a/tests/decode_unittests.c +++ b/tests/decode_unittests.c @@ -1,3 +1,5 @@ +#define NANOPB_INTERNALS + #include #include #include "pb_decode.h" @@ -17,11 +19,11 @@ bool stream_callback(pb_istream_t *stream, uint8_t *buf, size_t count) } /* Verifies that the stream passed to callback matches the byte array pointed to by arg. */ -bool callback_check(pb_istream_t *stream, const pb_field_t *field, void *arg) +bool callback_check(pb_istream_t *stream, const pb_field_t *field, void **arg) { int i; uint8_t byte; - pb_bytes_array_t *ref = (pb_bytes_array_t*) arg; + pb_bytes_array_t *ref = (pb_bytes_array_t*) *arg; for (i = 0; i < ref->size; i++) { @@ -287,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");