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

Unified Diff: base/files/file_unittest.cc

Issue 2797283002: Fixing std::swap(x, x) in base. (Closed)
Patch Set: Removing NOTREACHED from copy assignment. Created 3 years, 8 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/files/file.cc ('k') | base/pickle.cc » ('j') | base/values_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_unittest.cc
diff --git a/base/files/file_unittest.cc b/base/files/file_unittest.cc
index 66c312b60d4cff0d296384d829e529db94a74d28..8275bac769c04f133fce7a182e36bb0686560b08 100644
--- a/base/files/file_unittest.cc
+++ b/base/files/file_unittest.cc
@@ -105,6 +105,16 @@ TEST(FileTest, Create) {
EXPECT_FALSE(base::PathExists(file_path));
}
+TEST(FileTest, SelfSwap) {
+ base::ScopedTempDir temp_dir;
+ ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
+ FilePath file_path = temp_dir.GetPath().AppendASCII("create_file_1");
+ File file(file_path,
+ base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_DELETE_ON_CLOSE);
+ std::swap(file, file);
dcheng 2017/04/05 21:01:19 Slight nit: the standard idiom is: using std::swa
dyaroshev 2017/04/05 21:06:48 Done.
+ EXPECT_TRUE(file.IsValid());
+}
+
TEST(FileTest, Async) {
base::ScopedTempDir temp_dir;
ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
« no previous file with comments | « base/files/file.cc ('k') | base/pickle.cc » ('j') | base/values_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698