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

Side by Side Diff: net/disk_cache/blockfile/block_bitmaps_v3_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/disk_cache/blockfile/addr.h" 5 #include "net/disk_cache/blockfile/addr.h"
6 #include "net/disk_cache/blockfile/block_bitmaps_v3.h" 6 #include "net/disk_cache/blockfile/block_bitmaps_v3.h"
7 #include "net/disk_cache/blockfile/block_files.h" 7 #include "net/disk_cache/blockfile/block_files.h"
8 #include "net/disk_cache/blockfile/disk_format_base.h" 8 #include "net/disk_cache/blockfile/disk_format_base.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 15 matching lines...) Expand all
26 } 26 }
27 27
28 block_bitmaps.Init(bitmaps); 28 block_bitmaps.Init(bitmaps);
29 29
30 // Create a bunch of entries. 30 // Create a bunch of entries.
31 const int kSize = 100; 31 const int kSize = 100;
32 disk_cache::Addr address[kSize]; 32 disk_cache::Addr address[kSize];
33 for (int i = 0; i < kSize; i++) { 33 for (int i = 0; i < kSize; i++) {
34 SCOPED_TRACE(i); 34 SCOPED_TRACE(i);
35 int block_size = i % 4 + 1; 35 int block_size = i % 4 + 1;
36 ASSERT_TRUE(block_bitmaps.CreateBlock(disk_cache::BLOCK_1K, block_size, 36 ASSERT_TRUE(block_bitmaps.CreateBlock(
37 &address[i])); 37 disk_cache::BLOCK_1K, block_size, &address[i]));
38 EXPECT_EQ(disk_cache::BLOCK_1K, address[i].file_type()); 38 EXPECT_EQ(disk_cache::BLOCK_1K, address[i].file_type());
39 EXPECT_EQ(block_size, address[i].num_blocks()); 39 EXPECT_EQ(block_size, address[i].num_blocks());
40 int start = address[i].start_block(); 40 int start = address[i].start_block();
41 41
42 // Verify that the allocated entry doesn't cross a 4 block boundary. 42 // Verify that the allocated entry doesn't cross a 4 block boundary.
43 EXPECT_EQ(start / 4, (start + block_size - 1) / 4); 43 EXPECT_EQ(start / 4, (start + block_size - 1) / 4);
44 } 44 }
45 45
46 for (int i = 0; i < kSize; i++) { 46 for (int i = 0; i < kSize; i++) {
47 SCOPED_TRACE(i); 47 SCOPED_TRACE(i);
48 EXPECT_TRUE(block_bitmaps.IsValid(address[i])); 48 EXPECT_TRUE(block_bitmaps.IsValid(address[i]));
49 } 49 }
50 50
51 // The first part of the allocation map should be completely filled. We used 51 // The first part of the allocation map should be completely filled. We used
52 // 10 bits per each of four entries, so 250 bits total. All entries should go 52 // 10 bits per each of four entries, so 250 bits total. All entries should go
53 // to the third file. 53 // to the third file.
54 uint8* buffer = reinterpret_cast<uint8*>(&headers[2].allocation_map); 54 uint8* buffer = reinterpret_cast<uint8*>(&headers[2].allocation_map);
55 for (int i = 0; i < 29; i++) { 55 for (int i = 0; i < 29; i++) {
56 SCOPED_TRACE(i); 56 SCOPED_TRACE(i);
57 EXPECT_EQ(0xff, buffer[i]); 57 EXPECT_EQ(0xff, buffer[i]);
58 } 58 }
59 59
60 for (int i = 0; i < kSize; i++) { 60 for (int i = 0; i < kSize; i++) {
61 SCOPED_TRACE(i); 61 SCOPED_TRACE(i);
62 block_bitmaps.DeleteBlock(address[i]); 62 block_bitmaps.DeleteBlock(address[i]);
63 } 63 }
64 64
65 // The allocation map should be empty. 65 // The allocation map should be empty.
66 for (int i =0; i < 50; i++) { 66 for (int i = 0; i < 50; i++) {
67 SCOPED_TRACE(i); 67 SCOPED_TRACE(i);
68 EXPECT_EQ(0, buffer[i]); 68 EXPECT_EQ(0, buffer[i]);
69 } 69 }
70 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698