Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nanopb/nanopb.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarco Nilsson <marco@zyax.se>2024-01-11 17:53:03 +0300
committerPetteri Aimonen <jpa@github.mail.kapsi.fi>2024-01-11 18:07:07 +0300
commit423c03b626a861a7b3a08a2d411e23aefd58827b (patch)
tree48811357b7af07b12707cf61a35c12e28a4b2f5d /tests
parente586761f1f9ec1ffd39b943392daa9f1a6d03c03 (diff)
Add additional test.HEADmaster
One test that will cause the build to fail if sizing is emitted on repeated fields, and one test that verifies that sizing _is_ emitted on repeated fields with fixed sizes.
Diffstat (limited to 'tests')
-rw-r--r--tests/cxx_descriptor/SConscript2
-rw-r--r--tests/cxx_descriptor/message.proto12
-rw-r--r--tests/cxx_descriptor/message_descriptor.cc2
3 files changed, 15 insertions, 1 deletions
diff --git a/tests/cxx_descriptor/SConscript b/tests/cxx_descriptor/SConscript
index 1b609b7..3a798ae 100644
--- a/tests/cxx_descriptor/SConscript
+++ b/tests/cxx_descriptor/SConscript
@@ -24,5 +24,5 @@ for std in ["c++03", "c++11", "c++14", "c++17", "c++20"]:
o1 = e.Object('message_descriptor_{}'.format(std), 'message_descriptor.cc')
o2 = e.Object('message.pb_{}'.format(std), 'message.pb.c')
- p = e.Program([o1, o2])
+ p = e.Program([o1, o2, "$COMMON/pb_common.o"])
e.RunTest(p)
diff --git a/tests/cxx_descriptor/message.proto b/tests/cxx_descriptor/message.proto
index 74f6b67..bf074e8 100644
--- a/tests/cxx_descriptor/message.proto
+++ b/tests/cxx_descriptor/message.proto
@@ -20,3 +20,15 @@ message MyMessageWithoutMsgid {
optional uint32 field = 1;
}
+// This message is not used in the tests but is rather a sentry message that
+// will trigger a build failure if the generator decides to create a size
+// variable for fields which are not size bound. Note that this only works as
+// long as the C++ interface for sizing wraps the C interface.
+message MyMessageWithoutSize {
+ repeated uint32 field = 1;
+}
+
+message MyMessageWithSizeBoundRepeatedFields {
+ option (nanopb_msgopt).max_count = 100;
+ repeated uint32 field = 1;
+}
diff --git a/tests/cxx_descriptor/message_descriptor.cc b/tests/cxx_descriptor/message_descriptor.cc
index 0644834..149000b 100644
--- a/tests/cxx_descriptor/message_descriptor.cc
+++ b/tests/cxx_descriptor/message_descriptor.cc
@@ -21,6 +21,8 @@ extern "C" int main() {
TEST(MessageDescriptor<MyNonEmptyMessage>::size ==
MyNonEmptyMessage_size);
+ TEST(MessageDescriptor<MyMessageWithSizeBoundRepeatedFields>::size ==
+ MyMessageWithSizeBoundRepeatedFields_size);
TEST(MessageDescriptor<MyEmptyMessage>::fields() == MyEmptyMessage_fields);
TEST(MessageDescriptor<MyNonEmptyMessage>::fields() ==