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

Unified Diff: base/memory/ref_counted_unittest.cc

Issue 609593004: Add an explicit bool conversion to scoped_refptr<T>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix WMI? Created 6 years, 3 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
« no previous file with comments | « base/memory/ref_counted.h ('k') | chrome/installer/util/wmi.cc » ('j') | 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 e8eb0fd90f6c507912299eec14a53ef015e027c2..265f31d0ac2b1a9fd3296c6cdfd7a27b277a0e8a 100644
--- a/base/memory/ref_counted_unittest.cc
+++ b/base/memory/ref_counted_unittest.cc
@@ -60,3 +60,20 @@ TEST(RefCountedUnitTest, ScopedRefPtrToSelf) {
check->SelfDestruct();
EXPECT_TRUE(ScopedRefPtrToSelf::was_destroyed());
}
+
+TEST(RefCountedUnitTest, ScopedRefPtrBooleanOperations) {
+ scoped_refptr<SelfAssign> p1 = new SelfAssign;
+ scoped_refptr<SelfAssign> p2;
+ EXPECT_TRUE(p1);
+ EXPECT_FALSE(!p1);
+ EXPECT_TRUE(!p2);
+ EXPECT_FALSE(p2);
+ EXPECT_NE(p1, p2);
+ SelfAssign* raw_p = new SelfAssign;
+ p2 = raw_p;
+ EXPECT_NE(p1, p2);
+ EXPECT_EQ(raw_p, p2);
+ p2 = p1;
+ EXPECT_NE(raw_p, p2);
+ EXPECT_EQ(p1, p2);
+}
« no previous file with comments | « base/memory/ref_counted.h ('k') | chrome/installer/util/wmi.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698