aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar ncteisen <ncteisen@gmail.com>2018-07-27 02:11:55 -0700
committerGravatar ncteisen <ncteisen@gmail.com>2018-07-27 02:11:55 -0700
commit012ddf15efb51e9b592c7cde6d3ba60aa685e818 (patch)
treef671b7f4b982913c80accd8da04e6d2ecaa029de /test
parent1f533d2ae562f6664e707c0390629b40b0fb1957 (diff)
parent78aca7bf85fee5eb9c47b430ce20452cec1faf2d (diff)
Merge branch 'ref_counted_ptr_polymorphism_fix' of https://github.com/markdroth/grpc into channelz-subchannels
Diffstat (limited to 'test')
-rw-r--r--test/core/channel/channel_trace_test.cc10
-rw-r--r--test/core/gprpp/ref_counted_ptr_test.cc26
2 files changed, 30 insertions, 6 deletions
diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc
index 3d6aff03eb..efa625bccf 100644
--- a/test/core/channel/channel_trace_test.cc
+++ b/test/core/channel/channel_trace_test.cc
@@ -187,8 +187,8 @@ TEST_P(ChannelTracerTest, ComplexTest) {
AddSimpleTrace(&tracer);
AddSimpleTrace(&tracer);
AddSimpleTrace(&tracer);
- sc1.reset(nullptr);
- sc2.reset(nullptr);
+ sc1.reset();
+ sc2.reset();
}
// Test a case in which the parent channel has subchannels and the subchannels
@@ -234,9 +234,9 @@ TEST_P(ChannelTracerTest, TestNesting) {
grpc_slice_from_static_string("subchannel one inactive"), sc1);
AddSimpleTrace(&tracer);
ValidateChannelTrace(&tracer, 8, GetParam());
- sc1.reset(nullptr);
- sc2.reset(nullptr);
- conn1.reset(nullptr);
+ sc1.reset();
+ sc2.reset();
+ conn1.reset();
}
INSTANTIATE_TEST_CASE_P(ChannelTracerTestSweep, ChannelTracerTest,
diff --git a/test/core/gprpp/ref_counted_ptr_test.cc b/test/core/gprpp/ref_counted_ptr_test.cc
index aa30b72282..6df6e348c6 100644
--- a/test/core/gprpp/ref_counted_ptr_test.cc
+++ b/test/core/gprpp/ref_counted_ptr_test.cc
@@ -127,7 +127,7 @@ TEST(RefCountedPtr, ResetFromNonNullToNull) {
TEST(RefCountedPtr, ResetFromNullToNull) {
RefCountedPtr<Foo> foo;
EXPECT_EQ(nullptr, foo.get());
- foo.reset(nullptr);
+ foo.reset();
EXPECT_EQ(nullptr, foo.get());
}
@@ -175,6 +175,30 @@ TEST(RefCountedPtr, RefCountedWithTracing) {
foo->Unref(DEBUG_LOCATION, "foo");
}
+class Parent : public RefCounted<Parent> {
+ public:
+ Parent() {}
+};
+
+class Child : public Parent {
+ public:
+ Child() {}
+};
+
+void FunctionTakingParent(RefCountedPtr<Parent> o) {}
+
+void FunctionTakingChild(RefCountedPtr<Child> o) {}
+
+TEST(RefCountedPtr, CanPassChildToFunctionExpectingParent) {
+ RefCountedPtr<Child> child = MakeRefCounted<Child>();
+ FunctionTakingParent(child);
+}
+
+TEST(RefCountedPtr, CanPassChildToFunctionExpectingChild) {
+ RefCountedPtr<Child> child = MakeRefCounted<Child>();
+ FunctionTakingChild(child);
+}
+
} // namespace
} // namespace testing
} // namespace grpc_core