diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-02 18:29:37 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-02 18:29:37 +0200 |
commit | b9e1b4435a406a8a27c078ea05dee1240e51704a (patch) | |
tree | 3bd5e75d001d0c1d57710c47375af5c8ba84c26c /CAN-binder/libs/nanopb/tests/missing_fields/missing_fields.c | |
parent | 0242c26c2f5dc96387bca7efb118364c800f4ee7 (diff) |
Added external libraries from openXC CMake files.
Now libraries are cleanly included and built.
Change-Id: Iaa85639578b55b2da8357bc438426403e2cca8de
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/libs/nanopb/tests/missing_fields/missing_fields.c')
-rw-r--r-- | CAN-binder/libs/nanopb/tests/missing_fields/missing_fields.c | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/CAN-binder/libs/nanopb/tests/missing_fields/missing_fields.c b/CAN-binder/libs/nanopb/tests/missing_fields/missing_fields.c deleted file mode 100644 index 8aded827..00000000 --- a/CAN-binder/libs/nanopb/tests/missing_fields/missing_fields.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Checks that missing required fields are detected properly */ - -#include <stdio.h> -#include <pb_encode.h> -#include <pb_decode.h> -#include "missing_fields.pb.h" - -int main() -{ - uint8_t buffer[512]; - size_t size; - - /* Create a message with one missing field */ - { - MissingField msg = {0}; - pb_ostream_t stream = pb_ostream_from_buffer(buffer, sizeof(buffer)); - - if (!pb_encode(&stream, MissingField_fields, &msg)) - { - printf("Encode failed.\n"); - return 1; - } - - size = stream.bytes_written; - } - - /* Test that it decodes properly if we don't require that field */ - { - MissingField msg = {0}; - pb_istream_t stream = pb_istream_from_buffer(buffer, size); - - if (!pb_decode(&stream, MissingField_fields, &msg)) - { - printf("Decode failed: %s\n", PB_GET_ERROR(&stream)); - return 2; - } - } - - /* Test that it does *not* decode properly if we require the field */ - { - AllFields msg = {0}; - pb_istream_t stream = pb_istream_from_buffer(buffer, size); - - if (pb_decode(&stream, AllFields_fields, &msg)) - { - printf("Decode didn't detect missing field.\n"); - return 3; - } - } - - return 0; /* All ok */ -} - |