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

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

Issue 656033009: Convert ARRAYSIZE_UNSAFE -> arraysize in base/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « base/debug/stack_trace_posix.cc ('k') | base/i18n/icu_string_conversions_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/file_proxy.h" 5 #include "base/files/file_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 for (size_t i = 0; i < buffer_.size(); ++i) { 260 for (size_t i = 0; i < buffer_.size(); ++i) {
261 EXPECT_EQ(expected_data[i], buffer_[i]); 261 EXPECT_EQ(expected_data[i], buffer_[i]);
262 } 262 }
263 } 263 }
264 264
265 TEST_F(FileProxyTest, WriteAndFlush) { 265 TEST_F(FileProxyTest, WriteAndFlush) {
266 FileProxy proxy(file_task_runner()); 266 FileProxy proxy(file_task_runner());
267 CreateProxy(File::FLAG_CREATE | File::FLAG_WRITE, &proxy); 267 CreateProxy(File::FLAG_CREATE | File::FLAG_WRITE, &proxy);
268 268
269 const char data[] = "foo!"; 269 const char data[] = "foo!";
270 int data_bytes = ARRAYSIZE_UNSAFE(data); 270 int data_bytes = arraysize(data);
271 proxy.Write(0, data, data_bytes, 271 proxy.Write(0, data, data_bytes,
272 Bind(&FileProxyTest::DidWrite, weak_factory_.GetWeakPtr())); 272 Bind(&FileProxyTest::DidWrite, weak_factory_.GetWeakPtr()));
273 MessageLoop::current()->Run(); 273 MessageLoop::current()->Run();
274 EXPECT_EQ(File::FILE_OK, error_); 274 EXPECT_EQ(File::FILE_OK, error_);
275 EXPECT_EQ(data_bytes, bytes_written_); 275 EXPECT_EQ(data_bytes, bytes_written_);
276 276
277 // Flush the written data. (So that the following read should always 277 // Flush the written data. (So that the following read should always
278 // succeed. On some platforms it may work with or without this flush.) 278 // succeed. On some platforms it may work with or without this flush.)
279 proxy.Flush(Bind(&FileProxyTest::DidFinish, weak_factory_.GetWeakPtr())); 279 proxy.Flush(Bind(&FileProxyTest::DidFinish, weak_factory_.GetWeakPtr()));
280 MessageLoop::current()->Run(); 280 MessageLoop::current()->Run();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 char buffer[53]; 361 char buffer[53];
362 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53)); 362 EXPECT_EQ(53, base::ReadFile(test_path(), buffer, 53));
363 int i = 0; 363 int i = 0;
364 for (; i < 10; ++i) 364 for (; i < 10; ++i)
365 EXPECT_EQ(kTestData[i], buffer[i]); 365 EXPECT_EQ(kTestData[i], buffer[i]);
366 for (; i < 53; ++i) 366 for (; i < 53; ++i)
367 EXPECT_EQ(0, buffer[i]); 367 EXPECT_EQ(0, buffer[i]);
368 } 368 }
369 369
370 } // namespace base 370 } // namespace base
OLDNEW
« no previous file with comments | « base/debug/stack_trace_posix.cc ('k') | base/i18n/icu_string_conversions_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698