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

Side by Side Diff: net/disk_cache/addr_unittest.cc

Issue 16837003: Disk cache: Update Addr to handle file format version 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/addr.h" 5 #include "net/disk_cache/addr.h"
6 #include "net/disk_cache/disk_cache_test_base.h" 6 #include "net/disk_cache/disk_cache_test_base.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace disk_cache { 9 namespace disk_cache {
10 10
(...skipping 18 matching lines...) Expand all
29 Addr addr3(BLOCK_4K, 0x44, 0x41508, 0x952536); 29 Addr addr3(BLOCK_4K, 0x44, 0x41508, 0x952536);
30 EXPECT_EQ(BLOCK_4K, addr3.file_type()); 30 EXPECT_EQ(BLOCK_4K, addr3.file_type());
31 EXPECT_EQ(4, addr3.num_blocks()); 31 EXPECT_EQ(4, addr3.num_blocks());
32 EXPECT_EQ(8, addr3.FileNumber()); 32 EXPECT_EQ(8, addr3.FileNumber());
33 EXPECT_EQ(0x2536, addr3.start_block()); 33 EXPECT_EQ(0x2536, addr3.start_block());
34 EXPECT_EQ(4096, addr3.BlockSize()); 34 EXPECT_EQ(4096, addr3.BlockSize());
35 } 35 }
36 36
37 TEST_F(DiskCacheTest, CacheAddr_SanityCheck) { 37 TEST_F(DiskCacheTest, CacheAddr_SanityCheck) {
38 // First a few valid values. 38 // First a few valid values.
39 EXPECT_TRUE(Addr(0).SanityCheck()); 39 EXPECT_TRUE(Addr(0).SanityCheckV2());
40 EXPECT_TRUE(Addr(0x80001000).SanityCheck()); 40 EXPECT_TRUE(Addr(0x80001000).SanityCheckV2());
gavinp 2013/06/13 23:38:27 Can we use the multiargument constructor to Addr t
rvargas (doing something else) 2013/06/14 02:15:44 part of the purpose of this test is to go through
41 EXPECT_TRUE(Addr(0xC3FFFFFF).SanityCheck()); 41 EXPECT_TRUE(Addr(0xC3FFFFFF).SanityCheckV2());
42 EXPECT_TRUE(Addr(0xC0FFFFFF).SanityCheck()); 42 EXPECT_TRUE(Addr(0xC0FFFFFF).SanityCheckV2());
43 EXPECT_TRUE(Addr(0xD0001000).SanityCheckV3());
43 44
44 // Not initialized. 45 // Not initialized.
45 EXPECT_FALSE(Addr(0x20).SanityCheck()); 46 EXPECT_FALSE(Addr(0x20).SanityCheckV2());
46 EXPECT_FALSE(Addr(0x10001000).SanityCheck()); 47 EXPECT_FALSE(Addr(0x10001000).SanityCheckV2());
47 48
48 // Invalid file type. 49 // Invalid file type.
49 EXPECT_FALSE(Addr(0xD0001000).SanityCheck()); 50 EXPECT_FALSE(Addr(0xD0001000).SanityCheckV2());
50 EXPECT_FALSE(Addr(0xF0000000).SanityCheck()); 51 EXPECT_FALSE(Addr(0xE0001000).SanityCheckV3());
52 EXPECT_FALSE(Addr(0xF0000000).SanityCheckV2());
51 53
52 // Reserved bits. 54 // Reserved bits.
53 EXPECT_FALSE(Addr(0x14000000).SanityCheck()); 55 EXPECT_FALSE(Addr(0x14000000).SanityCheckV2());
54 EXPECT_FALSE(Addr(0x18000000).SanityCheck()); 56 EXPECT_FALSE(Addr(0x18000000).SanityCheckV2());
55 } 57 }
56 58
57 } // namespace disk_cache 59 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698