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/enum_sizes | |
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/enum_sizes')
3 files changed, 0 insertions, 170 deletions
diff --git a/CAN-binder/libs/nanopb/tests/enum_sizes/SConscript b/CAN-binder/libs/nanopb/tests/enum_sizes/SConscript deleted file mode 100644 index 048592e..0000000 --- a/CAN-binder/libs/nanopb/tests/enum_sizes/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -# Test that different sizes of enum fields are properly encoded and decoded. - -Import('env') - -env.NanopbProto('enumsizes') - -p = env.Program(["enumsizes_unittests.c", - "enumsizes.pb.c", - "$COMMON/pb_encode.o", - "$COMMON/pb_decode.o", - "$COMMON/pb_common.o"]) -env.RunTest(p) diff --git a/CAN-binder/libs/nanopb/tests/enum_sizes/enumsizes.proto b/CAN-binder/libs/nanopb/tests/enum_sizes/enumsizes.proto deleted file mode 100644 index a85d416..0000000 --- a/CAN-binder/libs/nanopb/tests/enum_sizes/enumsizes.proto +++ /dev/null @@ -1,86 +0,0 @@ -/* Test handling of enums with different value ranges. - * Depending on compiler and the packed_enum setting, the datatypes - * for enums can be either signed or unsigned. In past this has caused - * a bit of a problem for the encoder/decoder (issue #164). - */ - -syntax = "proto2"; - -import 'nanopb.proto'; - -option (nanopb_fileopt).long_names = false; - -enum UnpackedUint8 { - option (nanopb_enumopt).packed_enum = false; - UU8_MIN = 0; - UU8_MAX = 255; -} - -enum PackedUint8 { - option (nanopb_enumopt).packed_enum = true; - PU8_MIN = 0; - PU8_MAX = 255; -} - -enum UnpackedInt8 { - option (nanopb_enumopt).packed_enum = false; - UI8_MIN = -128; - UI8_MAX = 127; -} - -enum PackedInt8 { - option (nanopb_enumopt).packed_enum = true; - PI8_MIN = -128; - PI8_MAX = 127; -} - -enum UnpackedUint16 { - option (nanopb_enumopt).packed_enum = false; - UU16_MIN = 0; - UU16_MAX = 65535; -} - -enum PackedUint16 { - option (nanopb_enumopt).packed_enum = true; - PU16_MIN = 0; - PU16_MAX = 65535; -} - -enum UnpackedInt16 { - option (nanopb_enumopt).packed_enum = false; - UI16_MIN = -32768; - UI16_MAX = 32767; -} - -enum PackedInt16 { - option (nanopb_enumopt).packed_enum = true; - PI16_MIN = -32768; - PI16_MAX = 32767; -} - -/* Protobuf supports enums up to 32 bits. - * The 32 bit case is covered by HugeEnum in the alltypes test. - */ - -message PackedEnums { - required PackedUint8 u8_min = 1; - required PackedUint8 u8_max = 2; - required PackedInt8 i8_min = 3; - required PackedInt8 i8_max = 4; - required PackedUint16 u16_min = 5; - required PackedUint16 u16_max = 6; - required PackedInt16 i16_min = 7; - required PackedInt16 i16_max = 8; -} - -message UnpackedEnums { - required UnpackedUint8 u8_min = 1; - required UnpackedUint8 u8_max = 2; - required UnpackedInt8 i8_min = 3; - required UnpackedInt8 i8_max = 4; - required UnpackedUint16 u16_min = 5; - required UnpackedUint16 u16_max = 6; - required UnpackedInt16 i16_min = 7; - required UnpackedInt16 i16_max = 8; -} - diff --git a/CAN-binder/libs/nanopb/tests/enum_sizes/enumsizes_unittests.c b/CAN-binder/libs/nanopb/tests/enum_sizes/enumsizes_unittests.c deleted file mode 100644 index 5606895..0000000 --- a/CAN-binder/libs/nanopb/tests/enum_sizes/enumsizes_unittests.c +++ /dev/null @@ -1,72 +0,0 @@ -#include <stdio.h> -#include <string.h> -#include <pb_decode.h> -#include <pb_encode.h> -#include "unittests.h" -#include "enumsizes.pb.h" - -int main() -{ - int status = 0; - - UnpackedEnums msg1 = { - UU8_MIN, UU8_MAX, - UI8_MIN, UI8_MAX, - UU16_MIN, UU16_MAX, - UI16_MIN, UI16_MAX, - }; - - PackedEnums msg2; - UnpackedEnums msg3; - uint8_t buf[256]; - size_t msgsize; - - COMMENT("Step 1: unpacked enums -> protobuf"); - { - pb_ostream_t s = pb_ostream_from_buffer(buf, sizeof(buf)); - TEST(pb_encode(&s, UnpackedEnums_fields, &msg1)); - msgsize = s.bytes_written; - } - - COMMENT("Step 2: protobuf -> packed enums"); - { - pb_istream_t s = pb_istream_from_buffer(buf, msgsize); - TEST(pb_decode(&s, PackedEnums_fields, &msg2)); - - TEST(msg1.u8_min == (int)msg2.u8_min); - TEST(msg1.u8_max == (int)msg2.u8_max); - TEST(msg1.i8_min == (int)msg2.i8_min); - TEST(msg1.i8_max == (int)msg2.i8_max); - TEST(msg1.u16_min == (int)msg2.u16_min); - TEST(msg1.u16_max == (int)msg2.u16_max); - TEST(msg1.i16_min == (int)msg2.i16_min); - TEST(msg1.i16_max == (int)msg2.i16_max); - } - - COMMENT("Step 3: packed enums -> protobuf"); - { - pb_ostream_t s = pb_ostream_from_buffer(buf, sizeof(buf)); - TEST(pb_encode(&s, PackedEnums_fields, &msg2)); - msgsize = s.bytes_written; - } - - COMMENT("Step 4: protobuf -> unpacked enums"); - { - pb_istream_t s = pb_istream_from_buffer(buf, msgsize); - TEST(pb_decode(&s, UnpackedEnums_fields, &msg3)); - - TEST(msg1.u8_min == (int)msg3.u8_min); - TEST(msg1.u8_max == (int)msg3.u8_max); - TEST(msg1.i8_min == (int)msg3.i8_min); - TEST(msg1.i8_max == (int)msg3.i8_max); - TEST(msg1.u16_min == (int)msg2.u16_min); - TEST(msg1.u16_max == (int)msg2.u16_max); - TEST(msg1.i16_min == (int)msg2.i16_min); - TEST(msg1.i16_max == (int)msg2.i16_max); - } - - if (status != 0) - fprintf(stdout, "\n\nSome tests FAILED!\n"); - - return status; -} |