summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cpp.cc20
-rw-r--r--tests/test_def.c18
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_cpp.cc b/tests/test_cpp.cc
index 370c7b0..7ca5a0d 100644
--- a/tests/test_cpp.cc
+++ b/tests/test_cpp.cc
@@ -433,6 +433,25 @@ class StringBufTesterSizeTMethodNoHandlerDataNoHandle
}
};
+class StringBufTesterBoolMethodNoHandlerDataNoHandle
+ : public StringBufTesterBase {
+ public:
+ typedef StringBufTesterBoolMethodNoHandlerDataNoHandle ME;
+ void Register(upb::Handlers* h, const upb::FieldDef* f) {
+ UPB_UNUSED(f);
+ ASSERT(h->SetStringHandler(f, UpbMakeHandler(&ME::Handler)));
+ handler_data_val_ = kExpectedHandlerData;
+ }
+
+ private:
+ bool Handler(const char *buf, size_t len) {
+ ASSERT(buf == &buf_);
+ seen_ = true;
+ len_ = len;
+ return true;
+ }
+};
+
class StartMsgTesterBase {
public:
// We don't need the FieldDef it will create, but the test harness still
@@ -1124,6 +1143,7 @@ int run_tests(int argc, char *argv[]) {
TestHandler<StringBufTesterVoidFunctionWithHandlerDataNoHandle>();
TestHandler<StringBufTesterVoidFunctionWithHandlerDataWithHandle>();
TestHandler<StringBufTesterSizeTMethodNoHandlerDataNoHandle>();
+ TestHandler<StringBufTesterBoolMethodNoHandlerDataNoHandle>();
TestMismatchedTypes();
diff --git a/tests/test_def.c b/tests/test_def.c
index 7efd2b0..92b461f 100644
--- a/tests/test_def.c
+++ b/tests/test_def.c
@@ -25,6 +25,23 @@ static void test_empty_symtab() {
upb_symtab_unref(s, &s);
}
+static void test_noreftracking() {
+ // Reftracking is not required; clients can pass UPB_UNTRACKED_REF for owner.
+ upb_msgdef *md = upb_msgdef_new(UPB_UNTRACKED_REF);
+ upb_msgdef_ref(md, UPB_UNTRACKED_REF);
+
+ // Clients can mix tracked and untracked refs.
+ upb_msgdef_ref(md, &md);
+
+ upb_msgdef_unref(md, UPB_UNTRACKED_REF);
+ upb_msgdef_unref(md, UPB_UNTRACKED_REF);
+
+ // Call some random function on the messagedef to test that it is alive.
+ ASSERT(!upb_msgdef_isfrozen(md));
+
+ upb_msgdef_unref(md, &md);
+}
+
static upb_symtab *load_test_proto(void *owner) {
upb_symtab *s = upb_symtab_new(owner);
ASSERT(s);
@@ -271,5 +288,6 @@ int run_tests(int argc, char *argv[]) {
test_replacement();
test_freeze_free();
test_partial_freeze();
+ test_noreftracking();
return 0;
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback