Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: base/memory/ref_counted_unittest.cc

Issue 1993433002: Adds equality operators for comparing scoped_refptr with nullptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adds operators for handling nullptr on lhs Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« base/memory/ref_counted.h ('K') | « base/memory/ref_counted.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/ref_counted_unittest.cc
diff --git a/base/memory/ref_counted_unittest.cc b/base/memory/ref_counted_unittest.cc
index 54f62cf4cc579cf0525b23386956144a7753ba09..5c85a1fd1bdc3f5e88e81689c462da1fd7ece7bb 100644
--- a/base/memory/ref_counted_unittest.cc
+++ b/base/memory/ref_counted_unittest.cc
@@ -204,6 +204,16 @@ TEST(RefCountedUnitTest, Equality) {
EXPECT_NE(p2, p1);
}
+TEST(RefCountedUnitTest, NullptrEquality) {
+ scoped_refptr<SelfAssign> ptr_to_an_instance(new SelfAssign);
+ scoped_refptr<SelfAssign> null_ptr;
danakj 2016/05/18 01:12:34 nit: ptr_to_nullptr might be easier to read here
Rob Percival 2016/05/18 01:17:01 Done.
+
+ EXPECT_NE(nullptr, ptr_to_an_instance);
+ EXPECT_NE(ptr_to_an_instance, nullptr);
+ EXPECT_EQ(nullptr, null_ptr);
+ EXPECT_EQ(null_ptr, nullptr);
+}
+
TEST(RefCountedUnitTest, ConvertibleEquality) {
scoped_refptr<Derived> p1(new Derived);
scoped_refptr<SelfAssign> p2;
« base/memory/ref_counted.h ('K') | « base/memory/ref_counted.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698