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

Side by Side Diff: test/cctest/test-hashmap.cc

Issue 2369963002: [base] Remove PointersMatch, making a separate std::equals hashmap (Closed)
Patch Set: Fix the other simulators Created 4 years, 2 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 | « test/cctest/test-api.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 16 matching lines...) Expand all
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 29
30 #include "src/v8.h" 30 #include "src/v8.h"
31 #include "test/cctest/cctest.h" 31 #include "test/cctest/cctest.h"
32 32
33 #include "src/base/hashmap.h" 33 #include "src/base/hashmap.h"
34 34
35 using namespace v8::internal; 35 using namespace v8::internal;
36 36
37 static bool DefaultMatchFun(void* a, void* b) {
38 return a == b;
39 }
40
41 37
42 typedef uint32_t (*IntKeyHash)(uint32_t key); 38 typedef uint32_t (*IntKeyHash)(uint32_t key);
43 39
44 40
45 class IntSet { 41 class IntSet {
46 public: 42 public:
47 explicit IntSet(IntKeyHash hash) : hash_(hash), map_(DefaultMatchFun) {} 43 explicit IntSet(IntKeyHash hash) : hash_(hash) {}
48 44
49 void Insert(int x) { 45 void Insert(int x) {
50 CHECK_NE(0, x); // 0 corresponds to (void*)NULL - illegal key value 46 CHECK_NE(0, x); // 0 corresponds to (void*)NULL - illegal key value
51 v8::base::HashMap::Entry* p = 47 v8::base::HashMap::Entry* p =
52 map_.LookupOrInsert(reinterpret_cast<void*>(x), hash_(x)); 48 map_.LookupOrInsert(reinterpret_cast<void*>(x), hash_(x));
53 CHECK(p != NULL); // insert is set! 49 CHECK(p != NULL); // insert is set!
54 CHECK_EQ(reinterpret_cast<void*>(x), p->key); 50 CHECK_EQ(reinterpret_cast<void*>(x), p->key);
55 // we don't care about p->value 51 // we don't care about p->value
56 } 52 }
57 53
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 } 166 }
171 } 167 }
172 CHECK_EQ(0u, set.occupancy()); 168 CHECK_EQ(0u, set.occupancy());
173 } 169 }
174 170
175 171
176 TEST(HashSet) { 172 TEST(HashSet) {
177 TestSet(Hash, 100); 173 TestSet(Hash, 100);
178 TestSet(CollisionHash, 50); 174 TestSet(CollisionHash, 50);
179 } 175 }
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698