aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-09-12 13:27:56 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-09-12 13:27:56 +0300
commit936cfdc675c2dc3580c2459e8b1773a1d0bf9a8b (patch)
tree3337c87f74cb16b66ef4b5dda501ce0cc9392bc1 /tests
parent708084e7883a95dd7fd315cdc909f6664491c043 (diff)
Expand the multiple_files test case to include oneofs and enums
Diffstat (limited to 'tests')
-rw-r--r--tests/multiple_files/SConscript6
-rw-r--r--tests/multiple_files/callbacks2.proto9
-rw-r--r--tests/multiple_files/multifile1.proto (renamed from tests/multiple_files/callbacks.proto)12
-rw-r--r--tests/multiple_files/multifile2.proto21
-rw-r--r--tests/multiple_files/test_multiple_files.c14
5 files changed, 48 insertions, 14 deletions
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/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/callbacks.proto b/tests/multiple_files/multifile1.proto
index ccd1edd8..79cf0387 100644
--- a/tests/multiple_files/callbacks.proto
+++ b/tests/multiple_files/multifile1.proto
@@ -14,3 +14,15 @@ message TestMessage {
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 <stdio.h>
#include <pb_encode.h>
-#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;
}