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

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: rvalue&& all the things 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..bdb3ad10d0601bf0b0bc4afec30fa8d4d0952f23 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,26 @@ 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(kSecond, values_freed[0]);
danakj 2015/03/10 20:56:33 nit: you dont have to check [0] again
Robert Sesek 2015/03/10 21:00:40 Done.
+ 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