Added missing functions.

pull/13171/head
Josh Haberman 6 years ago
parent c4327e55ac
commit 0dbbfd1f80
  1. 20
      tests/test_cpp.cc
  2. 10
      upb/def.c

@ -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[]) {

@ -745,6 +745,11 @@ void upb_msg_field_iter_setdone(upb_msg_field_iter *iter) {
upb_inttable_iter_setdone(iter);
}
bool upb_msg_field_iter_isequal(const upb_msg_field_iter * iter1,
const upb_msg_field_iter * iter2) {
return upb_inttable_iter_isequal(iter1, iter2);
}
void upb_msg_oneof_begin(upb_msg_oneof_iter *iter, const upb_msgdef *m) {
upb_strtable_begin(iter, &m->ntof);
/* We need to skip past any initial fields. */
@ -774,6 +779,11 @@ void upb_msg_oneof_iter_setdone(upb_msg_oneof_iter *iter) {
upb_strtable_iter_setdone(iter);
}
bool upb_msg_oneof_iter_isequal(const upb_msg_oneof_iter *iter1,
const upb_msg_oneof_iter *iter2) {
return upb_strtable_iter_isequal(iter1, iter2);
}
/* upb_oneofdef ***************************************************************/
const char *upb_oneofdef_name(const upb_oneofdef *o) {

Loading…
Cancel
Save