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

Side by Side Diff: runtime/vm/hash_table_test.cc

Issue 1934263003: - Add a new constructor to the hash table classes that allow handles to be passed in instead of cre… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review-comments Created 4 years, 7 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 | « runtime/vm/hash_table.h ('k') | runtime/vm/object.h » ('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 (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <cstring> 6 #include <cstring>
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 num_deleted -= table.IsDeleted(i); 56 num_deleted -= table.IsDeleted(i);
57 } 57 }
58 EXPECT_EQ(0, num_unused); 58 EXPECT_EQ(0, num_unused);
59 EXPECT_EQ(0, num_occupied); 59 EXPECT_EQ(0, num_occupied);
60 EXPECT_EQ(0, num_deleted); 60 EXPECT_EQ(0, num_deleted);
61 } 61 }
62 62
63 63
64 TEST_CASE(HashTable) { 64 TEST_CASE(HashTable) {
65 typedef HashTable<TestTraits, 2, 1> Table; 65 typedef HashTable<TestTraits, 2, 1> Table;
66 Table table(HashTables::New<Table>(5)); 66 Table table(Thread::Current()->zone(), HashTables::New<Table>(5));
67 // Ensure that we did get at least 5 entries. 67 // Ensure that we did get at least 5 entries.
68 EXPECT_LE(5, table.NumEntries()); 68 EXPECT_LE(5, table.NumEntries());
69 EXPECT_EQ(0, table.NumOccupied()); 69 EXPECT_EQ(0, table.NumOccupied());
70 Validate(table); 70 Validate(table);
71 EXPECT_EQ(-1, table.FindKey("a")); 71 EXPECT_EQ(-1, table.FindKey("a"));
72 72
73 // Insertion and lookup. 73 // Insertion and lookup.
74 intptr_t a_entry = -1; 74 intptr_t a_entry = -1;
75 EXPECT(!table.FindKeyOrDeletedOrUnused("a", &a_entry)); 75 EXPECT(!table.FindKeyOrDeletedOrUnused("a", &a_entry));
76 EXPECT_NE(-1, a_entry); 76 EXPECT_NE(-1, a_entry);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 TEST_CASE(Maps) { 298 TEST_CASE(Maps) {
299 for (intptr_t initial_capacity = 0; 299 for (intptr_t initial_capacity = 0;
300 initial_capacity < 32; 300 initial_capacity < 32;
301 ++initial_capacity) { 301 ++initial_capacity) {
302 TestMap<UnorderedHashMap<TestTraits> >(initial_capacity, false); 302 TestMap<UnorderedHashMap<TestTraits> >(initial_capacity, false);
303 TestMap<EnumIndexHashMap<TestTraits> >(initial_capacity, true); 303 TestMap<EnumIndexHashMap<TestTraits> >(initial_capacity, true);
304 } 304 }
305 } 305 }
306 306
307 } // namespace dart 307 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/hash_table.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698