diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-20 10:24:05 +0000 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-06-20 10:24:05 +0000 |
commit | 32e25cbca210a359b09768537b6f443fe90a3070 (patch) | |
tree | 3309794c15d8a8f8e9c1c08cad072ee1378813ba /CAN-binder/libs/nanopb/tests/inline/inline_unittests.c | |
parent | 76c43dec62b2e21cd6446360c00d4fe6b437533f (diff) |
Separation Generator to a dedicated repo
Change-Id: Id94831651c3266861435272a6e36c7884bef2c45
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/libs/nanopb/tests/inline/inline_unittests.c')
-rw-r--r-- | CAN-binder/libs/nanopb/tests/inline/inline_unittests.c | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/CAN-binder/libs/nanopb/tests/inline/inline_unittests.c b/CAN-binder/libs/nanopb/tests/inline/inline_unittests.c deleted file mode 100644 index b5834c7e..00000000 --- a/CAN-binder/libs/nanopb/tests/inline/inline_unittests.c +++ /dev/null @@ -1,73 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <pb_decode.h> -#include <pb_encode.h> -#include "unittests.h" -#include "inline.pb.h" - -int main() -{ - int status = 0; - int i = 0; - COMMENT("Test inline byte fields"); - - { - Message1 msg1 = Message1_init_zero; - TEST(sizeof(msg1.data) == 32); - } - - { - Message1 msg1 = Message1_init_zero; - pb_byte_t msg1_buffer[Message1_size]; - pb_ostream_t ostream = pb_ostream_from_buffer(msg1_buffer, Message1_size); - Message1 msg1_deserialized = Message1_init_zero; - pb_istream_t istream = pb_istream_from_buffer(msg1_buffer, Message1_size); - - for (i = 0; i < 32; i++) { - msg1.data[i] = i; - } - - TEST(pb_encode(&ostream, Message1_fields, &msg1)); - TEST(ostream.bytes_written == Message1_size); - - TEST(pb_decode(&istream, Message1_fields, &msg1_deserialized)); - - TEST(istream.bytes_left == 0); - TEST(memcmp(&msg1_deserialized, &msg1, sizeof(msg1)) == 0); - } - - { - Message2 msg2 = {true, {0}}; - Message2 msg2_no_data = {false, {1}}; - pb_byte_t msg2_buffer[Message2_size]; - pb_ostream_t ostream = pb_ostream_from_buffer(msg2_buffer, Message2_size); - Message2 msg2_deserialized = Message2_init_zero; - pb_istream_t istream = pb_istream_from_buffer(msg2_buffer, Message2_size); - - for (i = 0; i < 64; i++) { - msg2.data[i] = i; - } - - TEST(pb_encode(&ostream, Message2_fields, &msg2)); - TEST(ostream.bytes_written == Message2_size); - - TEST(pb_decode(&istream, Message2_fields, &msg2_deserialized)); - - TEST(istream.bytes_left == 0); - TEST(memcmp(&msg2_deserialized, &msg2, sizeof(msg2)) == 0); - TEST(msg2_deserialized.has_data); - - memset(msg2_buffer, 0, sizeof(msg2_buffer)); - ostream = pb_ostream_from_buffer(msg2_buffer, Message2_size); - TEST(pb_encode(&ostream, Message2_fields, &msg2_no_data)); - istream = pb_istream_from_buffer(msg2_buffer, Message2_size); - TEST(pb_decode(&istream, Message2_fields, &msg2_deserialized)); - TEST(!msg2_deserialized.has_data); - TEST(memcmp(&msg2_deserialized, &msg2, sizeof(msg2)) != 0); - } - - if (status != 0) - fprintf(stdout, "\n\nSome tests FAILED!\n"); - - return status; -} |