diff options
author | Josh Haberman <jhaberman@gmail.com> | 2019-01-26 19:14:16 -0800 |
---|---|---|
committer | Josh Haberman <jhaberman@gmail.com> | 2019-01-26 19:14:16 -0800 |
commit | 0dbbfd1f8041f863f8f4c6ada33c4102520d406f (patch) | |
tree | 683774976841f5c9ee966000170272c6e82bc45d /tests | |
parent | c4327e55ac186383f909d52ddd363971a2c60562 (diff) |
Added missing functions.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_cpp.cc | 20 |
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[]) { |