diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-12-29 18:44:58 +0200 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2013-12-29 18:44:58 +0200 |
commit | f4146edf01b8226709538a46919c666c37ebb50b (patch) | |
tree | 0970b000552b97671d182e69356ffbb4904d746e | |
parent | 8da15d8b802b55d04bdd84761e3c15f03b97a650 (diff) |
Bring alltypes_pointer testcase up to date
-rw-r--r-- | tests/alltypes_pointer/SConscript | 9 | ||||
-rw-r--r-- | tests/alltypes_pointer/alltypes.proto | 93 | ||||
-rw-r--r-- | tests/alltypes_pointer/encode_alltypes_pointer.c | 18 |
3 files changed, 24 insertions, 96 deletions
diff --git a/tests/alltypes_pointer/SConscript b/tests/alltypes_pointer/SConscript index 81b9fa5..11a287a 100644 --- a/tests/alltypes_pointer/SConscript +++ b/tests/alltypes_pointer/SConscript @@ -3,6 +3,9 @@ Import("env") +c = Copy("$TARGET", "$SOURCE") +env.Command("alltypes.proto", "#alltypes/alltypes.proto", c) + env.NanopbProto(["alltypes", "alltypes.options"]) enc = env.Program(["encode_alltypes_pointer.c", "alltypes.pb.c", "$COMMON/pb_encode.o"]) @@ -12,7 +15,7 @@ env.RunTest("decode_alltypes.output", ["$BUILD/alltypes/decode_alltypes", "encod env.Compare(["encode_alltypes_pointer.output", "$BUILD/alltypes/encode_alltypes.output"]) # Do the same thing with the optional fields present -#env.RunTest("optionals.output", enc, ARGS = ['1']) -#env.RunTest("optionals.decout", ["$BUILD/alltypes/decode_alltypes", "optionals.output"], ARGS = ['1']) -#env.Compare(["optionals.output", "$BUILD/alltypes/optionals.output"]) +env.RunTest("optionals.output", enc, ARGS = ['1']) +env.RunTest("optionals.decout", ["$BUILD/alltypes/decode_alltypes", "optionals.output"], ARGS = ['1']) +env.Compare(["optionals.output", "$BUILD/alltypes/optionals.output"]) diff --git a/tests/alltypes_pointer/alltypes.proto b/tests/alltypes_pointer/alltypes.proto deleted file mode 100644 index a2cf8bb..0000000 --- a/tests/alltypes_pointer/alltypes.proto +++ /dev/null @@ -1,93 +0,0 @@ -message SubMessage { - required string substuff1 = 1 [default = "1"]; - required int32 substuff2 = 2 [default = 2]; - optional fixed32 substuff3 = 3 [default = 3]; -} - -message EmptyMessage { - -} - -enum MyEnum { - Zero = 0; - First = 1; - Second = 2; - Truth = 42; -} - -message AllTypes { - required int32 req_int32 = 1; - required int64 req_int64 = 2; - required uint32 req_uint32 = 3; - required uint64 req_uint64 = 4; - required sint32 req_sint32 = 5; - required sint64 req_sint64 = 6; - required bool req_bool = 7; - - required fixed32 req_fixed32 = 8; - required sfixed32 req_sfixed32= 9; - required float req_float = 10; - - required fixed64 req_fixed64 = 11; - required sfixed64 req_sfixed64= 12; - required double req_double = 13; - - required string req_string = 14; - required bytes req_bytes = 15; - required SubMessage req_submsg = 16; - required MyEnum req_enum = 17; - required EmptyMessage req_emptymsg = 18; - - - repeated int32 rep_int32 = 21; - repeated int64 rep_int64 = 22; - repeated uint32 rep_uint32 = 23; - repeated uint64 rep_uint64 = 24; - repeated sint32 rep_sint32 = 25; - repeated sint64 rep_sint64 = 26; - repeated bool rep_bool = 27; - - repeated fixed32 rep_fixed32 = 28; - repeated sfixed32 rep_sfixed32= 29; - repeated float rep_float = 30; - - repeated fixed64 rep_fixed64 = 31; - repeated sfixed64 rep_sfixed64= 32; - repeated double rep_double = 33; - - repeated string rep_string = 34; - repeated bytes rep_bytes = 35; - repeated SubMessage rep_submsg = 36; - repeated MyEnum rep_enum = 37; - repeated EmptyMessage rep_emptymsg = 38; - - optional int32 opt_int32 = 41 [default = 4041]; - optional int64 opt_int64 = 42 [default = 4042]; - optional uint32 opt_uint32 = 43 [default = 4043]; - optional uint64 opt_uint64 = 44 [default = 4044]; - optional sint32 opt_sint32 = 45 [default = 4045]; - optional sint64 opt_sint64 = 46 [default = 4046]; - optional bool opt_bool = 47 [default = false]; - - optional fixed32 opt_fixed32 = 48 [default = 4048]; - optional sfixed32 opt_sfixed32= 49 [default = 4049]; - optional float opt_float = 50 [default = 4050]; - - optional fixed64 opt_fixed64 = 51 [default = 4051]; - optional sfixed64 opt_sfixed64= 52 [default = 4052]; - optional double opt_double = 53 [default = 4053]; - - optional string opt_string = 54 [default = "4054"]; - optional bytes opt_bytes = 55 [default = "4055"]; - optional SubMessage opt_submsg = 56; - optional MyEnum opt_enum = 57 [default = Second]; - optional EmptyMessage opt_emptymsg = 58; - - // Just to make sure that the size of the fields has been calculated - // properly, i.e. otherwise a bug in last field might not be detected. - required int32 end = 99; - - - extensions 200 to 255; -} - diff --git a/tests/alltypes_pointer/encode_alltypes_pointer.c b/tests/alltypes_pointer/encode_alltypes_pointer.c index dabee73..6484ced 100644 --- a/tests/alltypes_pointer/encode_alltypes_pointer.c +++ b/tests/alltypes_pointer/encode_alltypes_pointer.c @@ -83,6 +83,23 @@ int main(int argc, char **argv) MyEnum opt_enum = MyEnum_Truth; EmptyMessage opt_emptymsg = {0}; + /* Values for the Limits message. */ + static int32_t int32_min = INT32_MIN; + static int32_t int32_max = INT32_MAX; + static uint32_t uint32_min = 0; + static uint32_t uint32_max = UINT32_MAX; + static int64_t int64_min = INT64_MIN; + static int64_t int64_max = INT64_MAX; + static uint64_t uint64_min = 0; + static uint64_t uint64_max = UINT64_MAX; + static HugeEnum enum_min = HugeEnum_Negative; + static HugeEnum enum_max = HugeEnum_Positive; + Limits req_limits = {&int32_min, &int32_max, + &uint32_min, &uint32_max, + &int64_min, &int64_max, + &uint64_min, &uint64_max, + &enum_min, &enum_max}; + /* Initialize the message struct with pointers to the fields. */ AllTypes alltypes = {0}; @@ -104,6 +121,7 @@ int main(int argc, char **argv) alltypes.req_submsg = &req_submsg; alltypes.req_enum = &req_enum; alltypes.req_emptymsg = &req_emptymsg; + alltypes.req_limits = &req_limits; alltypes.rep_int32_count = 5; alltypes.rep_int32 = rep_int32; alltypes.rep_int64_count = 5; alltypes.rep_int64 = rep_int64; |