X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Fencode_unittests.c;h=5578a0abfbc7168231c230eecc5e8c22f8ac9dc0;hb=64ac18c8848d3071a16065c84fca3b5e7210ce95;hp=ee7f7a3448e15d86d0d52e68f0884a184046971e;hpb=9966a8c9b680ada47b6bd5fe96405c0abaf773e4;p=apps%2Flow-level-can-service.git diff --git a/tests/encode_unittests.c b/tests/encode_unittests.c index ee7f7a3..5578a0a 100644 --- a/tests/encode_unittests.c +++ b/tests/encode_unittests.c @@ -2,6 +2,7 @@ #include #include "pb_encode.h" #include "unittests.h" +#include "unittestproto.pb.h" bool streamcallback(pb_ostream_t *stream, const uint8_t *buf, size_t count) { @@ -163,6 +164,27 @@ int main() TEST(WRITES(pb_enc_string(&s, NULL, &value), "\x00")) } + { + uint8_t buffer[10]; + pb_ostream_t s; + IntegerArray msg = {5, {1, 2, 3, 4, 5}}; + + COMMENT("Test pb_encode with int32 array") + + TEST(WRITES(pb_encode(&s, IntegerArray_fields, &msg), "\x0A\x05\x01\x02\x03\x04\x05")) + + msg.data_count = 0; + TEST(WRITES(pb_encode(&s, IntegerArray_fields, &msg), "")) + + msg.data_count = 10; + TEST(!pb_encode(&s, IntegerArray_fields, &msg)) + } + + { + + + } + if (status != 0) fprintf(stdout, "\n\nSome tests FAILED!\n");