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

Side by Side Diff: net/disk_cache/simple/simple_util_unittest.cc

Issue 14263005: Refactor our SimpleIndex file format and serialization to use Pickle instead of the previously bugg… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
(Empty)
1 // Copyright (c) 2013 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 "base/logging.h"
6 #include "net/disk_cache/simple/simple_util.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 using disk_cache::simple_util::ConvertEntryHashKeyToHexString;
10 using disk_cache::simple_util::GetEntryHashKeyAsHexString;
11 using disk_cache::simple_util::GetEntryHashKeyFromHexString;
12 using disk_cache::simple_util::GetEntryHashKey;
13
14 class SimpleUtilTest : public testing::Test {};
15
16 TEST_F(SimpleUtilTest, ConvertEntryHashKeyToHexString) {
17 EXPECT_EQ("0000000005f5e0ff",
18 ConvertEntryHashKeyToHexString(99999999));
19 EXPECT_EQ("7fffffffffffffff",
20 ConvertEntryHashKeyToHexString(9223372036854775807UL));
Philippe 2013/04/16 11:58:47 I think this test should be enough. You don't need
21 EXPECT_EQ("8000000000000000",
22 ConvertEntryHashKeyToHexString(9223372036854775808UL));
23 EXPECT_EQ("ffffffffffffffff",
24 ConvertEntryHashKeyToHexString(18446744073709551615UL));
25 }
26
27 TEST_F(SimpleUtilTest, GetEntryHashKey) {
28 EXPECT_EQ("7ac408c1dff9c84b",
29 GetEntryHashKeyAsHexString("http://www.amazon.com/"));
Philippe 2013/04/16 11:58:47 Same here. I would keep a test for the empty strin
30 EXPECT_EQ(0x7ac408c1dff9c84bUL, GetEntryHashKey("http://www.amazon.com/"));
31
32 EXPECT_EQ("9fe947998c2ccf47",
33 GetEntryHashKeyAsHexString("www.amazon.com"));
34 EXPECT_EQ(0x9fe947998c2ccf47UL, GetEntryHashKey("www.amazon.com"));
35
36 EXPECT_EQ("0d4b6b5eeea339da", GetEntryHashKeyAsHexString(""));
37 EXPECT_EQ(0x0d4b6b5eeea339daUL, GetEntryHashKey(""));
38
39 EXPECT_EQ("a68ac2ecc87dfd04", GetEntryHashKeyAsHexString("http://www.domain.co m/uoQ76Kb2QL5hzaVOSAKWeX0W9LfDLqphmRXpsfHN8tgF5lCsfTxlOVWY8vFwzhsRzoNYKhUIOTc5Tn UlT0vpdQflPyk2nh7vurXOj60cDnkG3nsrXMhFCsPjhcZAic2jKpF9F9TYRYQwJo81IMi6gY01RK3ZcN l8WGfqcvoZ702UIdetvR7kiaqo1czwSJCMjRFdG6EgMzgXrwE8DYMz4fWqoa1F1c1qwTCBk3yOcmGTbx sPSJK5QRyNea9IFLrBTjfE7ZlN2vZiI7adcDYJef.htm"));
40
41 EXPECT_EQ(0xa68ac2ecc87dfd04UL, GetEntryHashKey("http://www.domain.com/uoQ76Kb 2QL5hzaVOSAKWeX0W9LfDLqphmRXpsfHN8tgF5lCsfTxlOVWY8vFwzhsRzoNYKhUIOTc5TnUlT0vpdQf lPyk2nh7vurXOj60cDnkG3nsrXMhFCsPjhcZAic2jKpF9F9TYRYQwJo81IMi6gY01RK3ZcNl8WGfqcvo Z702UIdetvR7kiaqo1czwSJCMjRFdG6EgMzgXrwE8DYMz4fWqoa1F1c1qwTCBk3yOcmGTbxsPSJK5QRy Nea9IFLrBTjfE7ZlN2vZiI7adcDYJef.htm"));
42 }
43
44 TEST_F(SimpleUtilTest, GetEntryHashKeyFromHexString) {
45 uint64 hash_key = 0;
46 EXPECT_TRUE(GetEntryHashKeyFromHexString("0000000005f5e0ff", &hash_key));
Philippe 2013/04/16 11:58:47 Same here. I would have more fine grained non-dupl
47 EXPECT_EQ(99999999UL, hash_key);
48
49 EXPECT_TRUE(GetEntryHashKeyFromHexString("7ffffffffffffffF", &hash_key));
50 EXPECT_EQ(9223372036854775807UL, hash_key);
51
52 EXPECT_TRUE(GetEntryHashKeyFromHexString("8000000000000000", &hash_key));
53 EXPECT_EQ(9223372036854775808UL, hash_key);
54
55 EXPECT_TRUE(GetEntryHashKeyFromHexString("FFFFFFFFFFFFFFFF", &hash_key));
56 EXPECT_EQ(18446744073709551615UL, hash_key);
57
58 // Wrong hash string size.
59 EXPECT_FALSE(GetEntryHashKeyFromHexString("FFFFFFFFFFFFFFF", &hash_key));
60
61 // Wrong hash string size.
62 EXPECT_FALSE(GetEntryHashKeyFromHexString("FFFFFFFFFFFFFFFFF", &hash_key));
63
64 EXPECT_FALSE(GetEntryHashKeyFromHexString("iwr8wglhg8*(&1231((", &hash_key));
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698