From 2e1912374057355de4f4e0ceaff02c89d45f43e5 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 28 Nov 2017 15:18:28 -0800 Subject: Add tests for tracing versions of Ref() and Unref(). --- test/core/support/reference_counted_test.cc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'test/core') 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->Unref(); } -TEST(ReferenceCounted, HeapAllocatedWithExtraRef) { +TEST(ReferenceCounted, ExtraRef) { Foo* foo = New(); 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(); + 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 -- cgit v1.2.3