From 936cfdc675c2dc3580c2459e8b1773a1d0bf9a8b Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Sat, 12 Sep 2015 13:27:56 +0300 Subject: Expand the multiple_files test case to include oneofs and enums --- tests/multiple_files/SConscript | 6 +++--- tests/multiple_files/callbacks.proto | 16 ---------------- tests/multiple_files/callbacks2.proto | 9 --------- tests/multiple_files/multifile1.proto | 28 ++++++++++++++++++++++++++++ tests/multiple_files/multifile2.proto | 21 +++++++++++++++++++++ tests/multiple_files/test_multiple_files.c | 14 ++++++++++++-- 6 files changed, 64 insertions(+), 30 deletions(-) delete mode 100644 tests/multiple_files/callbacks.proto delete mode 100644 tests/multiple_files/callbacks2.proto create mode 100644 tests/multiple_files/multifile1.proto create mode 100644 tests/multiple_files/multifile2.proto (limited to 'tests/multiple_files') diff --git a/tests/multiple_files/SConscript b/tests/multiple_files/SConscript index 6b4f6b69..c3a82eb4 100644 --- a/tests/multiple_files/SConscript +++ b/tests/multiple_files/SConscript @@ -5,9 +5,9 @@ Import("env") incpath = env.Clone() incpath.Append(PROTOCPATH = '#multiple_files') -incpath.NanopbProto("callbacks") -incpath.NanopbProto("callbacks2") -test = incpath.Program(["test_multiple_files.c", "callbacks.pb.c", "callbacks2.pb.c"]) +incpath.NanopbProto("multifile1") +incpath.NanopbProto("multifile2") +test = incpath.Program(["test_multiple_files.c", "multifile1.pb.c", "multifile2.pb.c"]) env.RunTest(test) diff --git a/tests/multiple_files/callbacks.proto b/tests/multiple_files/callbacks.proto deleted file mode 100644 index ccd1edd8..00000000 --- a/tests/multiple_files/callbacks.proto +++ /dev/null @@ -1,16 +0,0 @@ -message SubMessage { - optional string stringvalue = 1; - repeated int32 int32value = 2; - repeated fixed32 fixed32value = 3; - repeated fixed64 fixed64value = 4; -} - -message TestMessage { - optional string stringvalue = 1; - repeated int32 int32value = 2; - repeated fixed32 fixed32value = 3; - repeated fixed64 fixed64value = 4; - optional SubMessage submsg = 5; - repeated string repeatedstring = 6; -} - diff --git a/tests/multiple_files/callbacks2.proto b/tests/multiple_files/callbacks2.proto deleted file mode 100644 index 9a55e15a..00000000 --- a/tests/multiple_files/callbacks2.proto +++ /dev/null @@ -1,9 +0,0 @@ -// Test if including generated header file for this file + implicit include of -// callbacks.pb.h still compiles. Used with test_compiles.c. -import "callbacks.proto"; - -message Callback2Message { - required TestMessage tstmsg = 1; - required SubMessage submsg = 2; -} - diff --git a/tests/multiple_files/multifile1.proto b/tests/multiple_files/multifile1.proto new file mode 100644 index 00000000..79cf0387 --- /dev/null +++ b/tests/multiple_files/multifile1.proto @@ -0,0 +1,28 @@ +message SubMessage { + optional string stringvalue = 1; + repeated int32 int32value = 2; + repeated fixed32 fixed32value = 3; + repeated fixed64 fixed64value = 4; +} + +message TestMessage { + optional string stringvalue = 1; + repeated int32 int32value = 2; + repeated fixed32 fixed32value = 3; + repeated fixed64 fixed64value = 4; + optional SubMessage submsg = 5; + repeated string repeatedstring = 6; +} + +enum SignedEnum { + SE_MIN = -128; + SE_MAX = 127; +} + +enum UnsignedEnum { + UE_MIN = 0; + UE_MAX = 255; +} + + + diff --git a/tests/multiple_files/multifile2.proto b/tests/multiple_files/multifile2.proto new file mode 100644 index 00000000..c5dcd406 --- /dev/null +++ b/tests/multiple_files/multifile2.proto @@ -0,0 +1,21 @@ +// Test if including generated header file for this file + implicit include of +// multifile2.pb.h still compiles. Used with test_compiles.c. +import "multifile1.proto"; + +message Callback2Message { + required TestMessage tstmsg = 1; + required SubMessage submsg = 2; +} + +message OneofMessage { + oneof msgs { + TestMessage tstmsg = 1; + SubMessage submsg = 2; + } +} + +message Enums { + required SignedEnum senum = 1; + required UnsignedEnum uenum = 2; +} + diff --git a/tests/multiple_files/test_multiple_files.c b/tests/multiple_files/test_multiple_files.c index 05722dc5..5134f03f 100644 --- a/tests/multiple_files/test_multiple_files.c +++ b/tests/multiple_files/test_multiple_files.c @@ -4,9 +4,19 @@ #include #include -#include "callbacks2.pb.h" +#include "unittests.h" +#include "multifile2.pb.h" + +/* Check that the size definition is obtained properly */ +static const int foo = OneofMessage_size; int main() { - return 0; + int status = 0; + + /* Check that enum signedness is detected properly */ + TEST(PB_LTYPE(Enums_fields[0].type) == PB_LTYPE_VARINT); + TEST(PB_LTYPE(Enums_fields[0].type) == PB_LTYPE_UVARINT); + + return status; } -- cgit 1.2.3-korg