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

Side by Side Diff: cc/hash_pair_unittest.cc

Issue 10911330: Add methods for hashing pairs of integer values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « cc/hash_pair.h ('k') | no next file » | 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) 2012 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 "cc/hash_pair.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 class HashPairTest : public testing::Test {
9 };
10
11 #define INSERT_PAIR_TEST(Type, value1, value2) \
12 { \
13 Type pair(value1, value2); \
14 base::hash_map<Type, int> map; \
15 map[pair] = 1; \
16 }
17
18 // Verify that a hash_map can be constructed for pairs of integers of various
19 // sizes.
20 TEST_F(HashPairTest, IntegerPairs) {
21 typedef std::pair<short, short> ShortShortPair;
22 typedef std::pair<short, int> ShortIntPair;
23 typedef std::pair<short, int32> ShortInt32Pair;
24 typedef std::pair<short, int64> ShortInt64Pair;
25
26 INSERT_PAIR_TEST(ShortShortPair, 4, 6);
27 INSERT_PAIR_TEST(ShortIntPair, 7, (1 << 30) + 4342);
28 INSERT_PAIR_TEST(ShortInt32Pair, 9, (1 << 29) + 378128932);
29 INSERT_PAIR_TEST(ShortInt64Pair, 10, (1LL << 60) + 78931732321);
30
31 typedef std::pair<int, short> IntShortPair;
32 typedef std::pair<int, int> IntIntPair;
33 typedef std::pair<int, int32> IntInt32Pair;
34 typedef std::pair<int, int64> IntInt64Pair;
35
36 INSERT_PAIR_TEST(IntShortPair, 4, 6);
37 INSERT_PAIR_TEST(IntIntPair, 7, (1 << 30) + 4342);
38 INSERT_PAIR_TEST(IntInt32Pair, 9, (1 << 29) + 378128932);
39 INSERT_PAIR_TEST(IntInt64Pair, 10, (1LL << 60) + 78931732321);
40
41 typedef std::pair<int32, short> Int32ShortPair;
42 typedef std::pair<int32, int> Int32IntPair;
43 typedef std::pair<int32, int32> Int32Int32Pair;
44 typedef std::pair<int32, int64> Int32Int64Pair;
45
46 INSERT_PAIR_TEST(Int32ShortPair, 4, 6);
47 INSERT_PAIR_TEST(Int32IntPair, 7, (1 << 30) + 4342);
48 INSERT_PAIR_TEST(Int32Int32Pair, 9, (1 << 29) + 378128932);
49 INSERT_PAIR_TEST(Int32Int64Pair, 10, (1LL << 60) + 78931732321);
50
51 typedef std::pair<int64, short> Int64ShortPair;
52 typedef std::pair<int64, int> Int64IntPair;
53 typedef std::pair<int64, int32> Int64Int32Pair;
54 typedef std::pair<int64, int64> Int64Int64Pair;
55
56 INSERT_PAIR_TEST(Int64ShortPair, 4, 6);
57 INSERT_PAIR_TEST(Int64IntPair, 7, (1 << 30) + 4342);
58 INSERT_PAIR_TEST(Int64Int32Pair, 9, (1 << 29) + 378128932);
59 INSERT_PAIR_TEST(Int64Int64Pair, 10, (1LL << 60) + 78931732321);
60 }
OLDNEW
« no previous file with comments | « cc/hash_pair.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698