summaryrefslogtreecommitdiffstats
path: root/CAN-binder/libs/nanopb/tests/extensions/decode_extensions.c
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-02 18:29:37 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-05-02 18:29:37 +0200
commitb9e1b4435a406a8a27c078ea05dee1240e51704a (patch)
tree3bd5e75d001d0c1d57710c47375af5c8ba84c26c /CAN-binder/libs/nanopb/tests/extensions/decode_extensions.c
parent0242c26c2f5dc96387bca7efb118364c800f4ee7 (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/extensions/decode_extensions.c')
-rw-r--r--CAN-binder/libs/nanopb/tests/extensions/decode_extensions.c60
1 files changed, 0 insertions, 60 deletions
diff --git a/CAN-binder/libs/nanopb/tests/extensions/decode_extensions.c b/CAN-binder/libs/nanopb/tests/extensions/decode_extensions.c
deleted file mode 100644
index e4374380..00000000
--- a/CAN-binder/libs/nanopb/tests/extensions/decode_extensions.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Test decoding of extension fields. */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <pb_decode.h>
-#include "alltypes.pb.h"
-#include "extensions.pb.h"
-#include "test_helpers.h"
-
-#define TEST(x) if (!(x)) { \
- printf("Test " #x " failed.\n"); \
- return 2; \
- }
-
-int main(int argc, char **argv)
-{
- uint8_t buffer[1024];
- size_t count;
- pb_istream_t stream;
-
- AllTypes alltypes = {0};
- int32_t extensionfield1;
- pb_extension_t ext1;
- ExtensionMessage extensionfield2;
- pb_extension_t ext2;
-
- /* Read the message data */
- SET_BINARY_MODE(stdin);
- count = fread(buffer, 1, sizeof(buffer), stdin);
- stream = pb_istream_from_buffer(buffer, count);
-
- /* Add the extensions */
- alltypes.extensions = &ext1;
-
- ext1.type = &AllTypes_extensionfield1;
- ext1.dest = &extensionfield1;
- ext1.next = &ext2;
-
- ext2.type = &ExtensionMessage_AllTypes_extensionfield2;
- ext2.dest = &extensionfield2;
- ext2.next = NULL;
-
- /* Decode the message */
- if (!pb_decode(&stream, AllTypes_fields, &alltypes))
- {
- printf("Parsing failed: %s\n", PB_GET_ERROR(&stream));
- return 1;
- }
-
- /* Check that the extensions decoded properly */
- TEST(ext1.found)
- TEST(extensionfield1 == 12345)
- TEST(ext2.found)
- TEST(strcmp(extensionfield2.test1, "test") == 0)
- TEST(extensionfield2.test2 == 54321)
-
- return 0;
-}
-