summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJosh Haberman <jhaberman@gmail.com>2019-01-26 19:14:16 -0800
committerJosh Haberman <jhaberman@gmail.com>2019-01-26 19:14:16 -0800
commit0dbbfd1f8041f863f8f4c6ada33c4102520d406f (patch)
tree683774976841f5c9ee966000170272c6e82bc45d /tests
parentc4327e55ac186383f909d52ddd363971a2c60562 (diff)
Added missing functions.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cpp.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc
index 86d7bc5..f1badc4 100644
--- a/tests/test_cpp.cc
+++ b/tests/test_cpp.cc
@@ -893,6 +893,26 @@ void TestHandlerDataDestruction() {
ASSERT(x == 0);
}
+void TestIteration() {
+ upb::SymbolTable symtab;
+ upb::MessageDefPtr md(upb_test_TestMessage_getmsgdef(symtab.ptr()));
+
+ // Test range-based for on both fields and oneofs (with the iterator adaptor).
+ int field_count = 0;
+ for (auto field : md.fields()) {
+ UPB_UNUSED(field);
+ field_count++;
+ }
+ ASSERT(field_count == md.field_count());
+
+ int oneof_count = 0;
+ for (auto oneof : md.oneofs()) {
+ UPB_UNUSED(oneof);
+ oneof_count++;
+ }
+ ASSERT(oneof_count == md.oneof_count());
+}
+
extern "C" {
int run_tests(int argc, char *argv[]) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback