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

Side by Side Diff: base/files/memory_mapped_file_unittest.cc

Issue 1479473002: base: Use std::move() instead of Pass() for real movable types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: basepass: missing-include Created 5 years 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 unified diff | Download patch
« no previous file with comments | « base/files/important_file_writer.cc ('k') | base/json/json_writer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/files/memory_mapped_file.h" 5 #include "base/files/memory_mapped_file.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 namespace { 14 namespace {
15 15
16 // Create a temporary buffer and fill it with a watermark sequence. 16 // Create a temporary buffer and fill it with a watermark sequence.
17 scoped_ptr<uint8[]> CreateTestBuffer(size_t size, size_t offset) { 17 scoped_ptr<uint8[]> CreateTestBuffer(size_t size, size_t offset) {
18 scoped_ptr<uint8[]> buf(new uint8[size]); 18 scoped_ptr<uint8[]> buf(new uint8[size]);
19 for (size_t i = 0; i < size; ++i) 19 for (size_t i = 0; i < size; ++i)
20 buf.get()[i] = static_cast<uint8>((offset + i) % 253); 20 buf.get()[i] = static_cast<uint8>((offset + i) % 253);
21 return buf.Pass(); 21 return buf;
22 } 22 }
23 23
24 // Check that the watermark sequence is consistent with the |offset| provided. 24 // Check that the watermark sequence is consistent with the |offset| provided.
25 bool CheckBufferContents(const uint8* data, size_t size, size_t offset) { 25 bool CheckBufferContents(const uint8* data, size_t size, size_t offset) {
26 scoped_ptr<uint8[]> test_data(CreateTestBuffer(size, offset)); 26 scoped_ptr<uint8[]> test_data(CreateTestBuffer(size, offset));
27 return memcmp(test_data.get(), data, size) == 0; 27 return memcmp(test_data.get(), data, size) == 0;
28 } 28 }
29 29
30 class MemoryMappedFileTest : public PlatformTest { 30 class MemoryMappedFileTest : public PlatformTest {
31 protected: 31 protected:
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 map.Initialize(file.Pass(), region); 161 map.Initialize(file.Pass(), region);
162 ASSERT_EQ(kPartialSize, map.length()); 162 ASSERT_EQ(kPartialSize, map.length());
163 ASSERT_TRUE(map.data() != NULL); 163 ASSERT_TRUE(map.data() != NULL);
164 EXPECT_TRUE(map.IsValid()); 164 EXPECT_TRUE(map.IsValid());
165 ASSERT_TRUE(CheckBufferContents(map.data(), kPartialSize, kOffset)); 165 ASSERT_TRUE(CheckBufferContents(map.data(), kPartialSize, kOffset));
166 } 166 }
167 167
168 } // namespace 168 } // namespace
169 169
170 } // namespace base 170 } // namespace base
OLDNEW
« no previous file with comments | « base/files/important_file_writer.cc ('k') | base/json/json_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698