aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2017-11-28 15:18:28 -0800
committerGravatar Mark D. Roth <roth@google.com>2017-11-28 15:18:28 -0800
commit2e1912374057355de4f4e0ceaff02c89d45f43e5 (patch)
treee3525f976a93c4015f052a1b4a358abd7663be91 /test/core
parent18d332d8ba1eb1077653ade055363081210e03a1 (diff)
Add tests for tracing versions of Ref() and Unref().
Diffstat (limited to 'test/core')
-rw-r--r--test/core/support/reference_counted_test.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/test/core/support/reference_counted_test.cc b/test/core/support/reference_counted_test.cc
index f6d2a2c309..778556d999 100644
--- a/test/core/support/reference_counted_test.cc
+++ b/test/core/support/reference_counted_test.cc
@@ -25,24 +25,43 @@
namespace grpc_core {
namespace testing {
+namespace {
class Foo : public ReferenceCounted {
public:
Foo() {}
};
-TEST(ReferenceCounted, HeapAllocated) {
+TEST(ReferenceCounted, Basic) {
Foo* foo = New<Foo>();
foo->Unref();
}
-TEST(ReferenceCounted, HeapAllocatedWithExtraRef) {
+TEST(ReferenceCounted, ExtraRef) {
Foo* foo = New<Foo>();
foo->Ref();
foo->Unref();
foo->Unref();
}
+TraceFlag foo_tracer(true, "foo");
+
+class FooWithTracing : public ReferenceCounted {
+ public:
+ FooWithTracing() : ReferenceCounted(&foo_tracer) {}
+};
+
+TEST(ReferenceCounted, WithTracing) {
+ FooWithTracing* foo = New<FooWithTracing>();
+ foo->Ref(DEBUG_LOCATION, "extra_ref");
+ foo->Unref(DEBUG_LOCATION, "extra_ref");
+ // Can use the no-argument methods, too.
+ foo->Ref();
+ foo->Unref();
+ foo->Unref(DEBUG_LOCATION, "original_ref");
+}
+
+} // namespace
} // namespace testing
} // namespace grpc_core