diff options
author | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2021-03-22 15:09:24 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2021-03-22 15:09:24 +0300 |
commit | 4d58171341df28c96e5de85889aca328237dfb36 (patch) | |
tree | 9720258122df529888d99651bca055c81a39d445 /tests | |
parent | a2ddaeb5a278c07df9fe6c92575e2cd65f20c100 (diff) |
Add test case for #637
Diffstat (limited to 'tests')
-rw-r--r-- | tests/regression/issue_637/SConscript | 9 | ||||
-rw-r--r-- | tests/regression/issue_637/oneof.proto | 18 | ||||
-rw-r--r-- | tests/regression/issue_637/other.proto | 6 | ||||
-rw-r--r-- | tests/regression/issue_637/test.c | 5 |
4 files changed, 38 insertions, 0 deletions
diff --git a/tests/regression/issue_637/SConscript b/tests/regression/issue_637/SConscript new file mode 100644 index 0000000..55319d9 --- /dev/null +++ b/tests/regression/issue_637/SConscript @@ -0,0 +1,9 @@ +# Regression test for #637: +# Generator produces incorrect output when a oneof is used + +Import("env") + +env.NanopbProto("other.proto") +env.NanopbProto(["oneof.proto", "other.proto"]) +env.Object("oneof.pb.c") +env.Object("test.c") diff --git a/tests/regression/issue_637/oneof.proto b/tests/regression/issue_637/oneof.proto new file mode 100644 index 0000000..ce47bf8 --- /dev/null +++ b/tests/regression/issue_637/oneof.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +import "other.proto"; + +message FirstOneof {} + +message Bar { + oneof content { + FirstOneof first = 1; + SecondOneof second = 2; + } +} + +message Foo { + Bar bar = 1; +} + + diff --git a/tests/regression/issue_637/other.proto b/tests/regression/issue_637/other.proto new file mode 100644 index 0000000..d4f72ef --- /dev/null +++ b/tests/regression/issue_637/other.proto @@ -0,0 +1,6 @@ +syntax = "proto3"; + +message SecondOneof { + repeated int32 foo = 1; +} + diff --git a/tests/regression/issue_637/test.c b/tests/regression/issue_637/test.c new file mode 100644 index 0000000..6a2d354 --- /dev/null +++ b/tests/regression/issue_637/test.c @@ -0,0 +1,5 @@ +/* This fakes the situation where other.proto is not found for some reason + * by making its size indefinite, but then defining it here manually. */ + +#define SecondOneof_size 5 +#include "oneof.pb.h" |