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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 | « net/disk_cache/blockfile/addr.cc ('k') | net/disk_cache/blockfile/backend_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/disk_cache/blockfile/addr.h"
6 #include "net/disk_cache/disk_cache_test_base.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace disk_cache {
10
11 TEST_F(DiskCacheTest, CacheAddr_Size) {
12 Addr addr1(0);
13 EXPECT_FALSE(addr1.is_initialized());
14
15 // The object should not be more expensive than the actual address.
16 EXPECT_EQ(sizeof(uint32), sizeof(addr1));
17 }
18
19 TEST_F(DiskCacheTest, CacheAddr_ValidValues) {
20 Addr addr2(BLOCK_1K, 3, 5, 25);
21 EXPECT_EQ(BLOCK_1K, addr2.file_type());
22 EXPECT_EQ(3, addr2.num_blocks());
23 EXPECT_EQ(5, addr2.FileNumber());
24 EXPECT_EQ(25, addr2.start_block());
25 EXPECT_EQ(1024, addr2.BlockSize());
26 }
27
28 TEST_F(DiskCacheTest, CacheAddr_InvalidValues) {
29 Addr addr3(BLOCK_4K, 0x44, 0x41508, 0x952536);
30 EXPECT_EQ(BLOCK_4K, addr3.file_type());
31 EXPECT_EQ(4, addr3.num_blocks());
32 EXPECT_EQ(8, addr3.FileNumber());
33 EXPECT_EQ(0x2536, addr3.start_block());
34 EXPECT_EQ(4096, addr3.BlockSize());
35 }
36
37 TEST_F(DiskCacheTest, CacheAddr_SanityCheck) {
38 // First a few valid values.
39 EXPECT_TRUE(Addr(0).SanityCheckV2());
40 EXPECT_TRUE(Addr(0x80001000).SanityCheckV2());
41 EXPECT_TRUE(Addr(0xC3FFFFFF).SanityCheckV2());
42 EXPECT_TRUE(Addr(0xC0FFFFFF).SanityCheckV2());
43 EXPECT_TRUE(Addr(0xD0001000).SanityCheckV3());
44
45 // Not initialized.
46 EXPECT_FALSE(Addr(0x20).SanityCheckV2());
47 EXPECT_FALSE(Addr(0x10001000).SanityCheckV2());
48
49 // Invalid file type.
50 EXPECT_FALSE(Addr(0xD0001000).SanityCheckV2());
51 EXPECT_FALSE(Addr(0xE0001000).SanityCheckV3());
52 EXPECT_FALSE(Addr(0xF0000000).SanityCheckV2());
53
54 // Reserved bits.
55 EXPECT_FALSE(Addr(0x14000000).SanityCheckV2());
56 EXPECT_FALSE(Addr(0x18000000).SanityCheckV2());
57 }
58
59 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/addr.cc ('k') | net/disk_cache/blockfile/backend_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698