| OLD | NEW |
| 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 <stdint.h> |
| 6 |
| 5 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 6 #include "base/logging.h" | 8 #include "base/logging.h" |
| 7 #include "net/disk_cache/blockfile/addr.h" | 9 #include "net/disk_cache/blockfile/addr.h" |
| 8 #include "net/disk_cache/blockfile/disk_format_v3.h" | 10 #include "net/disk_cache/blockfile/disk_format_v3.h" |
| 9 #include "net/disk_cache/blockfile/index_table_v3.h" | 11 #include "net/disk_cache/blockfile/index_table_v3.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 13 |
| 12 using disk_cache::EntryCell; | 14 using disk_cache::EntryCell; |
| 13 using disk_cache::IndexCell; | 15 using disk_cache::IndexCell; |
| 14 using disk_cache::IndexTable; | 16 using disk_cache::IndexTable; |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 221 |
| 220 source.last_part = 0x55; | 222 source.last_part = 0x55; |
| 221 EXPECT_EQ(3, GetChecksum(source)); | 223 EXPECT_EQ(3, GetChecksum(source)); |
| 222 | 224 |
| 223 source.first_part = 0x555555; | 225 source.first_part = 0x555555; |
| 224 EXPECT_EQ(2, GetChecksum(source)); | 226 EXPECT_EQ(2, GetChecksum(source)); |
| 225 | 227 |
| 226 source.last_part = 0; | 228 source.last_part = 0; |
| 227 EXPECT_EQ(1, GetChecksum(source)); | 229 EXPECT_EQ(1, GetChecksum(source)); |
| 228 | 230 |
| 229 source.first_part = GG_UINT64_C(0x8000000080000000); | 231 source.first_part = UINT64_C(0x8000000080000000); |
| 230 EXPECT_EQ(0, GetChecksum(source)); | 232 EXPECT_EQ(0, GetChecksum(source)); |
| 231 | 233 |
| 232 source.first_part = GG_UINT64_C(0x4000000040000000); | 234 source.first_part = UINT64_C(0x4000000040000000); |
| 233 EXPECT_EQ(2, GetChecksum(source)); | 235 EXPECT_EQ(2, GetChecksum(source)); |
| 234 | 236 |
| 235 source.first_part = GG_UINT64_C(0x200000020000000); | 237 source.first_part = UINT64_C(0x200000020000000); |
| 236 EXPECT_EQ(1, GetChecksum(source)); | 238 EXPECT_EQ(1, GetChecksum(source)); |
| 237 | 239 |
| 238 source.first_part = GG_UINT64_C(0x100000010010000); | 240 source.first_part = UINT64_C(0x100000010010000); |
| 239 EXPECT_EQ(3, GetChecksum(source)); | 241 EXPECT_EQ(3, GetChecksum(source)); |
| 240 | 242 |
| 241 source.first_part = 0x80008000; | 243 source.first_part = 0x80008000; |
| 242 EXPECT_EQ(0, GetChecksum(source)); | 244 EXPECT_EQ(0, GetChecksum(source)); |
| 243 | 245 |
| 244 source.first_part = GG_UINT64_C(0x800000008000); | 246 source.first_part = UINT64_C(0x800000008000); |
| 245 EXPECT_EQ(1, GetChecksum(source)); | 247 EXPECT_EQ(1, GetChecksum(source)); |
| 246 | 248 |
| 247 source.first_part = 0x8080; | 249 source.first_part = 0x8080; |
| 248 EXPECT_EQ(0, GetChecksum(source)); | 250 EXPECT_EQ(0, GetChecksum(source)); |
| 249 | 251 |
| 250 source.first_part = 0x800080; | 252 source.first_part = 0x800080; |
| 251 EXPECT_EQ(1, GetChecksum(source)); | 253 EXPECT_EQ(1, GetChecksum(source)); |
| 252 | 254 |
| 253 source.first_part = 0x88; | 255 source.first_part = 0x88; |
| 254 EXPECT_EQ(0, GetChecksum(source)); | 256 EXPECT_EQ(0, GetChecksum(source)); |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 | 699 |
| 698 uint32 hash = 0; | 700 uint32 hash = 0; |
| 699 disk_cache::Addr addr(disk_cache::BLOCK_ENTRIES, 1, 5, 6); | 701 disk_cache::Addr addr(disk_cache::BLOCK_ENTRIES, 1, 5, 6); |
| 700 EntryCell entry = index.CreateEntryCell(hash, addr); | 702 EntryCell entry = index.CreateEntryCell(hash, addr); |
| 701 EXPECT_TRUE(entry.IsValid()); | 703 EXPECT_TRUE(entry.IsValid()); |
| 702 | 704 |
| 703 index.OnBackupTimer(); | 705 index.OnBackupTimer(); |
| 704 int expected = (1024 + 512) / 8 + sizeof(disk_cache::IndexHeaderV3); | 706 int expected = (1024 + 512) / 8 + sizeof(disk_cache::IndexHeaderV3); |
| 705 EXPECT_EQ(expected, backend.buffer_len()); | 707 EXPECT_EQ(expected, backend.buffer_len()); |
| 706 } | 708 } |
| OLD | NEW |