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

Unified Diff: base/scoped_generic_unittest.cc

Issue 995093002: Add additional move support to ScopedGeneric in the form of operator=. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nit Created 5 years, 9 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/scoped_generic.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/scoped_generic_unittest.cc
diff --git a/base/scoped_generic_unittest.cc b/base/scoped_generic_unittest.cc
index f0dca22e693179b8d8c6d8c838ef9b07c61ea69a..b28e154372e6f07ffdec17eec07f25bbf9ad8d8c 100644
--- a/base/scoped_generic_unittest.cc
+++ b/base/scoped_generic_unittest.cc
@@ -85,7 +85,7 @@ TEST(ScopedGenericTest, ScopedGeneric) {
EXPECT_EQ(kSecond, values_freed[1]);
values_freed.clear();
- // Pass.
+ // Pass constructor.
{
ScopedInt a(kFirst, traits);
ScopedInt b(a.Pass());
@@ -93,8 +93,25 @@ TEST(ScopedGenericTest, ScopedGeneric) {
ASSERT_EQ(IntTraits::InvalidValue(), a.get());
ASSERT_EQ(kFirst, b.get());
}
+
ASSERT_EQ(1u, values_freed.size());
ASSERT_EQ(kFirst, values_freed[0]);
+ values_freed.clear();
+
+ // Pass assign.
+ {
+ ScopedInt a(kFirst, traits);
+ ScopedInt b(kSecond, traits);
+ b = a.Pass();
+ ASSERT_EQ(1u, values_freed.size());
+ EXPECT_EQ(kSecond, values_freed[0]);
+ ASSERT_EQ(IntTraits::InvalidValue(), a.get());
+ ASSERT_EQ(kFirst, b.get());
+ }
+
+ ASSERT_EQ(2u, values_freed.size());
+ EXPECT_EQ(kFirst, values_freed[1]);
+ values_freed.clear();
}
TEST(ScopedGenericTest, Operators) {
« no previous file with comments | « base/scoped_generic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698