summaryrefslogtreecommitdiffstats
path: root/tests/encode_unittests.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/encode_unittests.c')
-rw-r--r--tests/encode_unittests.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/encode_unittests.c b/tests/encode_unittests.c
index ee7f7a34..5578a0ab 100644
--- a/tests/encode_unittests.c
+++ b/tests/encode_unittests.c
@@ -2,6 +2,7 @@
#include <string.h>
#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");