PageRenderTime 46ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/libutils/tests/BasicHashtable_test.cpp

https://gitlab.com/infraredbg/android_system_core-mt6589
C++ | 577 lines | 446 code | 108 blank | 23 comment | 23 complexity | 7895930aa3090cd6ba2bd9062884aef7 MD5 | raw file
  1. /*
  2. * Copyright (C) 2011 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #define LOG_TAG "BasicHashtable_test"
  17. #include <utils/BasicHashtable.h>
  18. #include <cutils/log.h>
  19. #include <gtest/gtest.h>
  20. #include <unistd.h>
  21. namespace android {
  22. typedef int SimpleKey;
  23. typedef int SimpleValue;
  24. typedef key_value_pair_t<SimpleKey, SimpleValue> SimpleEntry;
  25. typedef BasicHashtable<SimpleKey, SimpleEntry> SimpleHashtable;
  26. struct ComplexKey {
  27. int k;
  28. explicit ComplexKey(int k) : k(k) {
  29. instanceCount += 1;
  30. }
  31. ComplexKey(const ComplexKey& other) : k(other.k) {
  32. instanceCount += 1;
  33. }
  34. ~ComplexKey() {
  35. instanceCount -= 1;
  36. }
  37. bool operator ==(const ComplexKey& other) const {
  38. return k == other.k;
  39. }
  40. bool operator !=(const ComplexKey& other) const {
  41. return k != other.k;
  42. }
  43. static ssize_t instanceCount;
  44. };
  45. ssize_t ComplexKey::instanceCount = 0;
  46. template<> inline hash_t hash_type(const ComplexKey& value) {
  47. return hash_type(value.k);
  48. }
  49. struct ComplexValue {
  50. int v;
  51. explicit ComplexValue(int v) : v(v) {
  52. instanceCount += 1;
  53. }
  54. ComplexValue(const ComplexValue& other) : v(other.v) {
  55. instanceCount += 1;
  56. }
  57. ~ComplexValue() {
  58. instanceCount -= 1;
  59. }
  60. static ssize_t instanceCount;
  61. };
  62. ssize_t ComplexValue::instanceCount = 0;
  63. typedef key_value_pair_t<ComplexKey, ComplexValue> ComplexEntry;
  64. typedef BasicHashtable<ComplexKey, ComplexEntry> ComplexHashtable;
  65. class BasicHashtableTest : public testing::Test {
  66. protected:
  67. virtual void SetUp() {
  68. ComplexKey::instanceCount = 0;
  69. ComplexValue::instanceCount = 0;
  70. }
  71. virtual void TearDown() {
  72. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(0, 0));
  73. }
  74. void assertInstanceCount(ssize_t keys, ssize_t values) {
  75. if (keys != ComplexKey::instanceCount || values != ComplexValue::instanceCount) {
  76. FAIL() << "Expected " << keys << " keys and " << values << " values "
  77. "but there were actually " << ComplexKey::instanceCount << " keys and "
  78. << ComplexValue::instanceCount << " values";
  79. }
  80. }
  81. public:
  82. template <typename TKey, typename TEntry>
  83. static void cookieAt(const BasicHashtable<TKey, TEntry>& h, size_t index,
  84. bool* collision, bool* present, hash_t* hash) {
  85. uint32_t cookie = h.cookieAt(index);
  86. *collision = cookie & BasicHashtable<TKey, TEntry>::Bucket::COLLISION;
  87. *present = cookie & BasicHashtable<TKey, TEntry>::Bucket::PRESENT;
  88. *hash = cookie & BasicHashtable<TKey, TEntry>::Bucket::HASH_MASK;
  89. }
  90. template <typename TKey, typename TEntry>
  91. static const void* getBuckets(const BasicHashtable<TKey, TEntry>& h) {
  92. return h.mBuckets;
  93. }
  94. };
  95. template <typename TKey, typename TValue>
  96. static size_t add(BasicHashtable<TKey, key_value_pair_t<TKey, TValue> >& h,
  97. const TKey& key, const TValue& value) {
  98. return h.add(hash_type(key), key_value_pair_t<TKey, TValue>(key, value));
  99. }
  100. template <typename TKey, typename TValue>
  101. static ssize_t find(BasicHashtable<TKey, key_value_pair_t<TKey, TValue> >& h,
  102. ssize_t index, const TKey& key) {
  103. return h.find(index, hash_type(key), key);
  104. }
  105. template <typename TKey, typename TValue>
  106. static bool remove(BasicHashtable<TKey, key_value_pair_t<TKey, TValue> >& h,
  107. const TKey& key) {
  108. ssize_t index = find(h, -1, key);
  109. if (index >= 0) {
  110. h.removeAt(index);
  111. return true;
  112. }
  113. return false;
  114. }
  115. template <typename TEntry>
  116. static void getKeyValue(const TEntry& entry, int* key, int* value);
  117. template <> void getKeyValue(const SimpleEntry& entry, int* key, int* value) {
  118. *key = entry.key;
  119. *value = entry.value;
  120. }
  121. template <> void getKeyValue(const ComplexEntry& entry, int* key, int* value) {
  122. *key = entry.key.k;
  123. *value = entry.value.v;
  124. }
  125. template <typename TKey, typename TValue>
  126. static void dump(BasicHashtable<TKey, key_value_pair_t<TKey, TValue> >& h) {
  127. ALOGD("hashtable %p, size=%u, capacity=%u, bucketCount=%u",
  128. &h, h.size(), h.capacity(), h.bucketCount());
  129. for (size_t i = 0; i < h.bucketCount(); i++) {
  130. bool collision, present;
  131. hash_t hash;
  132. BasicHashtableTest::cookieAt(h, i, &collision, &present, &hash);
  133. if (present) {
  134. int key, value;
  135. getKeyValue(h.entryAt(i), &key, &value);
  136. ALOGD(" [%3u] = collision=%d, present=%d, hash=0x%08x, key=%3d, value=%3d, "
  137. "hash_type(key)=0x%08x",
  138. i, collision, present, hash, key, value, hash_type(key));
  139. } else {
  140. ALOGD(" [%3u] = collision=%d, present=%d",
  141. i, collision, present);
  142. }
  143. }
  144. }
  145. TEST_F(BasicHashtableTest, DefaultConstructor_WithDefaultProperties) {
  146. SimpleHashtable h;
  147. EXPECT_EQ(0U, h.size());
  148. EXPECT_EQ(3U, h.capacity());
  149. EXPECT_EQ(5U, h.bucketCount());
  150. EXPECT_EQ(0.75f, h.loadFactor());
  151. }
  152. TEST_F(BasicHashtableTest, Constructor_WithNonUnityLoadFactor) {
  153. SimpleHashtable h(52, 0.8f);
  154. EXPECT_EQ(0U, h.size());
  155. EXPECT_EQ(77U, h.capacity());
  156. EXPECT_EQ(97U, h.bucketCount());
  157. EXPECT_EQ(0.8f, h.loadFactor());
  158. }
  159. TEST_F(BasicHashtableTest, Constructor_WithUnityLoadFactorAndExactCapacity) {
  160. SimpleHashtable h(46, 1.0f);
  161. EXPECT_EQ(0U, h.size());
  162. EXPECT_EQ(46U, h.capacity()); // must be one less than bucketCount because loadFactor == 1.0f
  163. EXPECT_EQ(47U, h.bucketCount());
  164. EXPECT_EQ(1.0f, h.loadFactor());
  165. }
  166. TEST_F(BasicHashtableTest, Constructor_WithUnityLoadFactorAndInexactCapacity) {
  167. SimpleHashtable h(42, 1.0f);
  168. EXPECT_EQ(0U, h.size());
  169. EXPECT_EQ(46U, h.capacity()); // must be one less than bucketCount because loadFactor == 1.0f
  170. EXPECT_EQ(47U, h.bucketCount());
  171. EXPECT_EQ(1.0f, h.loadFactor());
  172. }
  173. TEST_F(BasicHashtableTest, FindAddFindRemoveFind_OneEntry) {
  174. SimpleHashtable h;
  175. ssize_t index = find(h, -1, 8);
  176. ASSERT_EQ(-1, index);
  177. index = add(h, 8, 1);
  178. ASSERT_EQ(1U, h.size());
  179. ASSERT_EQ(index, find(h, -1, 8));
  180. ASSERT_EQ(8, h.entryAt(index).key);
  181. ASSERT_EQ(1, h.entryAt(index).value);
  182. index = find(h, index, 8);
  183. ASSERT_EQ(-1, index);
  184. ASSERT_TRUE(remove(h, 8));
  185. ASSERT_EQ(0U, h.size());
  186. index = find(h, -1, 8);
  187. ASSERT_EQ(-1, index);
  188. }
  189. TEST_F(BasicHashtableTest, FindAddFindRemoveFind_MultipleEntryWithUniqueKey) {
  190. const size_t N = 11;
  191. SimpleHashtable h;
  192. for (size_t i = 0; i < N; i++) {
  193. ssize_t index = find(h, -1, int(i));
  194. ASSERT_EQ(-1, index);
  195. index = add(h, int(i), int(i * 10));
  196. ASSERT_EQ(i + 1, h.size());
  197. ASSERT_EQ(index, find(h, -1, int(i)));
  198. ASSERT_EQ(int(i), h.entryAt(index).key);
  199. ASSERT_EQ(int(i * 10), h.entryAt(index).value);
  200. index = find(h, index, int(i));
  201. ASSERT_EQ(-1, index);
  202. }
  203. for (size_t i = N; --i > 0; ) {
  204. ASSERT_TRUE(remove(h, int(i))) << "i = " << i;
  205. ASSERT_EQ(i, h.size());
  206. ssize_t index = find(h, -1, int(i));
  207. ASSERT_EQ(-1, index);
  208. }
  209. }
  210. TEST_F(BasicHashtableTest, FindAddFindRemoveFind_MultipleEntryWithDuplicateKey) {
  211. const size_t N = 11;
  212. const int K = 1;
  213. SimpleHashtable h;
  214. for (size_t i = 0; i < N; i++) {
  215. ssize_t index = find(h, -1, K);
  216. if (i == 0) {
  217. ASSERT_EQ(-1, index);
  218. } else {
  219. ASSERT_NE(-1, index);
  220. }
  221. add(h, K, int(i));
  222. ASSERT_EQ(i + 1, h.size());
  223. index = -1;
  224. int values = 0;
  225. for (size_t j = 0; j <= i; j++) {
  226. index = find(h, index, K);
  227. ASSERT_GE(index, 0);
  228. ASSERT_EQ(K, h.entryAt(index).key);
  229. values |= 1 << h.entryAt(index).value;
  230. }
  231. ASSERT_EQ(values, (1 << (i + 1)) - 1);
  232. index = find(h, index, K);
  233. ASSERT_EQ(-1, index);
  234. }
  235. for (size_t i = N; --i > 0; ) {
  236. ASSERT_TRUE(remove(h, K)) << "i = " << i;
  237. ASSERT_EQ(i, h.size());
  238. ssize_t index = -1;
  239. for (size_t j = 0; j < i; j++) {
  240. index = find(h, index, K);
  241. ASSERT_GE(index, 0);
  242. ASSERT_EQ(K, h.entryAt(index).key);
  243. }
  244. index = find(h, index, K);
  245. ASSERT_EQ(-1, index);
  246. }
  247. }
  248. TEST_F(BasicHashtableTest, Clear_WhenAlreadyEmpty_DoesNothing) {
  249. SimpleHashtable h;
  250. h.clear();
  251. EXPECT_EQ(0U, h.size());
  252. EXPECT_EQ(3U, h.capacity());
  253. EXPECT_EQ(5U, h.bucketCount());
  254. EXPECT_EQ(0.75f, h.loadFactor());
  255. }
  256. TEST_F(BasicHashtableTest, Clear_AfterElementsAdded_RemovesThem) {
  257. SimpleHashtable h;
  258. add(h, 0, 0);
  259. add(h, 1, 0);
  260. h.clear();
  261. EXPECT_EQ(0U, h.size());
  262. EXPECT_EQ(3U, h.capacity());
  263. EXPECT_EQ(5U, h.bucketCount());
  264. EXPECT_EQ(0.75f, h.loadFactor());
  265. }
  266. TEST_F(BasicHashtableTest, Clear_AfterElementsAdded_DestroysThem) {
  267. ComplexHashtable h;
  268. add(h, ComplexKey(0), ComplexValue(0));
  269. add(h, ComplexKey(1), ComplexValue(0));
  270. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  271. h.clear();
  272. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(0, 0));
  273. EXPECT_EQ(0U, h.size());
  274. EXPECT_EQ(3U, h.capacity());
  275. EXPECT_EQ(5U, h.bucketCount());
  276. EXPECT_EQ(0.75f, h.loadFactor());
  277. }
  278. TEST_F(BasicHashtableTest, Remove_AfterElementsAdded_DestroysThem) {
  279. ComplexHashtable h;
  280. add(h, ComplexKey(0), ComplexValue(0));
  281. add(h, ComplexKey(1), ComplexValue(0));
  282. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  283. ASSERT_TRUE(remove(h, ComplexKey(0)));
  284. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(1, 1));
  285. ASSERT_TRUE(remove(h, ComplexKey(1)));
  286. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(0, 0));
  287. EXPECT_EQ(0U, h.size());
  288. EXPECT_EQ(3U, h.capacity());
  289. EXPECT_EQ(5U, h.bucketCount());
  290. EXPECT_EQ(0.75f, h.loadFactor());
  291. }
  292. TEST_F(BasicHashtableTest, Destructor_AfterElementsAdded_DestroysThem) {
  293. {
  294. ComplexHashtable h;
  295. add(h, ComplexKey(0), ComplexValue(0));
  296. add(h, ComplexKey(1), ComplexValue(0));
  297. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  298. } // h is destroyed here
  299. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(0, 0));
  300. }
  301. TEST_F(BasicHashtableTest, Next_WhenEmpty_ReturnsMinusOne) {
  302. SimpleHashtable h;
  303. ASSERT_EQ(-1, h.next(-1));
  304. }
  305. TEST_F(BasicHashtableTest, Next_WhenNonEmpty_IteratesOverAllEntries) {
  306. const int N = 88;
  307. SimpleHashtable h;
  308. for (int i = 0; i < N; i++) {
  309. add(h, i, i * 10);
  310. }
  311. bool set[N];
  312. memset(set, 0, sizeof(bool) * N);
  313. int count = 0;
  314. for (ssize_t index = -1; (index = h.next(index)) != -1; ) {
  315. ASSERT_GE(index, 0);
  316. ASSERT_LT(size_t(index), h.bucketCount());
  317. const SimpleEntry& entry = h.entryAt(index);
  318. ASSERT_GE(entry.key, 0);
  319. ASSERT_LT(entry.key, N);
  320. ASSERT_FALSE(set[entry.key]);
  321. ASSERT_EQ(entry.key * 10, entry.value);
  322. set[entry.key] = true;
  323. count += 1;
  324. }
  325. ASSERT_EQ(N, count);
  326. }
  327. TEST_F(BasicHashtableTest, Add_RehashesOnDemand) {
  328. SimpleHashtable h;
  329. size_t initialCapacity = h.capacity();
  330. size_t initialBucketCount = h.bucketCount();
  331. for (size_t i = 0; i < initialCapacity; i++) {
  332. add(h, int(i), 0);
  333. }
  334. EXPECT_EQ(initialCapacity, h.size());
  335. EXPECT_EQ(initialCapacity, h.capacity());
  336. EXPECT_EQ(initialBucketCount, h.bucketCount());
  337. add(h, -1, -1);
  338. EXPECT_EQ(initialCapacity + 1, h.size());
  339. EXPECT_GT(h.capacity(), initialCapacity);
  340. EXPECT_GT(h.bucketCount(), initialBucketCount);
  341. EXPECT_GT(h.bucketCount(), h.capacity());
  342. }
  343. TEST_F(BasicHashtableTest, Rehash_WhenCapacityAndBucketCountUnchanged_DoesNothing) {
  344. ComplexHashtable h;
  345. add(h, ComplexKey(0), ComplexValue(0));
  346. const void* oldBuckets = getBuckets(h);
  347. ASSERT_NE((void*)NULL, oldBuckets);
  348. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(1, 1));
  349. h.rehash(h.capacity(), h.loadFactor());
  350. ASSERT_EQ(oldBuckets, getBuckets(h));
  351. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(1, 1));
  352. }
  353. TEST_F(BasicHashtableTest, Rehash_WhenEmptyAndHasNoBuckets_ButDoesNotAllocateBuckets) {
  354. ComplexHashtable h;
  355. ASSERT_EQ((void*)NULL, getBuckets(h));
  356. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(0, 0));
  357. h.rehash(9, 1.0f);
  358. EXPECT_EQ(0U, h.size());
  359. EXPECT_EQ(10U, h.capacity());
  360. EXPECT_EQ(11U, h.bucketCount());
  361. EXPECT_EQ(1.0f, h.loadFactor());
  362. EXPECT_EQ((void*)NULL, getBuckets(h));
  363. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(0, 0));
  364. }
  365. TEST_F(BasicHashtableTest, Rehash_WhenEmptyAndHasBuckets_ReleasesBucketsAndSetsCapacity) {
  366. ComplexHashtable h(10);
  367. add(h, ComplexKey(0), ComplexValue(0));
  368. ASSERT_TRUE(remove(h, ComplexKey(0)));
  369. ASSERT_NE((void*)NULL, getBuckets(h));
  370. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(0, 0));
  371. h.rehash(0, 0.75f);
  372. EXPECT_EQ(0U, h.size());
  373. EXPECT_EQ(3U, h.capacity());
  374. EXPECT_EQ(5U, h.bucketCount());
  375. EXPECT_EQ(0.75f, h.loadFactor());
  376. EXPECT_EQ((void*)NULL, getBuckets(h));
  377. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(0, 0));
  378. }
  379. TEST_F(BasicHashtableTest, Rehash_WhenLessThanCurrentCapacity_ShrinksBuckets) {
  380. ComplexHashtable h(10);
  381. add(h, ComplexKey(0), ComplexValue(0));
  382. add(h, ComplexKey(1), ComplexValue(1));
  383. const void* oldBuckets = getBuckets(h);
  384. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  385. h.rehash(0, 0.75f);
  386. EXPECT_EQ(2U, h.size());
  387. EXPECT_EQ(3U, h.capacity());
  388. EXPECT_EQ(5U, h.bucketCount());
  389. EXPECT_EQ(0.75f, h.loadFactor());
  390. EXPECT_NE(oldBuckets, getBuckets(h));
  391. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  392. }
  393. TEST_F(BasicHashtableTest, CopyOnWrite) {
  394. ComplexHashtable h1;
  395. add(h1, ComplexKey(0), ComplexValue(0));
  396. add(h1, ComplexKey(1), ComplexValue(1));
  397. const void* originalBuckets = getBuckets(h1);
  398. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  399. ssize_t index0 = find(h1, -1, ComplexKey(0));
  400. EXPECT_GE(index0, 0);
  401. // copy constructor acquires shared reference
  402. ComplexHashtable h2(h1);
  403. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  404. ASSERT_EQ(originalBuckets, getBuckets(h2));
  405. EXPECT_EQ(h1.size(), h2.size());
  406. EXPECT_EQ(h1.capacity(), h2.capacity());
  407. EXPECT_EQ(h1.bucketCount(), h2.bucketCount());
  408. EXPECT_EQ(h1.loadFactor(), h2.loadFactor());
  409. EXPECT_EQ(index0, find(h2, -1, ComplexKey(0)));
  410. // operator= acquires shared reference
  411. ComplexHashtable h3;
  412. h3 = h2;
  413. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  414. ASSERT_EQ(originalBuckets, getBuckets(h3));
  415. EXPECT_EQ(h1.size(), h3.size());
  416. EXPECT_EQ(h1.capacity(), h3.capacity());
  417. EXPECT_EQ(h1.bucketCount(), h3.bucketCount());
  418. EXPECT_EQ(h1.loadFactor(), h3.loadFactor());
  419. EXPECT_EQ(index0, find(h3, -1, ComplexKey(0)));
  420. // editEntryAt copies shared contents
  421. h1.editEntryAt(index0).value.v = 42;
  422. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(4, 4));
  423. ASSERT_NE(originalBuckets, getBuckets(h1));
  424. EXPECT_EQ(42, h1.entryAt(index0).value.v);
  425. EXPECT_EQ(0, h2.entryAt(index0).value.v);
  426. EXPECT_EQ(0, h3.entryAt(index0).value.v);
  427. // clear releases reference to shared contents
  428. h2.clear();
  429. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(4, 4));
  430. EXPECT_EQ(0U, h2.size());
  431. ASSERT_NE(originalBuckets, getBuckets(h2));
  432. // operator= acquires shared reference, destroys unshared contents
  433. h1 = h3;
  434. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  435. ASSERT_EQ(originalBuckets, getBuckets(h1));
  436. EXPECT_EQ(h3.size(), h1.size());
  437. EXPECT_EQ(h3.capacity(), h1.capacity());
  438. EXPECT_EQ(h3.bucketCount(), h1.bucketCount());
  439. EXPECT_EQ(h3.loadFactor(), h1.loadFactor());
  440. EXPECT_EQ(index0, find(h1, -1, ComplexKey(0)));
  441. // add copies shared contents
  442. add(h1, ComplexKey(2), ComplexValue(2));
  443. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(5, 5));
  444. ASSERT_NE(originalBuckets, getBuckets(h1));
  445. EXPECT_EQ(3U, h1.size());
  446. EXPECT_EQ(0U, h2.size());
  447. EXPECT_EQ(2U, h3.size());
  448. // remove copies shared contents
  449. h1 = h3;
  450. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  451. ASSERT_EQ(originalBuckets, getBuckets(h1));
  452. h1.removeAt(index0);
  453. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(3, 3));
  454. ASSERT_NE(originalBuckets, getBuckets(h1));
  455. EXPECT_EQ(1U, h1.size());
  456. EXPECT_EQ(0U, h2.size());
  457. EXPECT_EQ(2U, h3.size());
  458. // rehash copies shared contents
  459. h1 = h3;
  460. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(2, 2));
  461. ASSERT_EQ(originalBuckets, getBuckets(h1));
  462. h1.rehash(10, 1.0f);
  463. ASSERT_NO_FATAL_FAILURE(assertInstanceCount(4, 4));
  464. ASSERT_NE(originalBuckets, getBuckets(h1));
  465. EXPECT_EQ(2U, h1.size());
  466. EXPECT_EQ(0U, h2.size());
  467. EXPECT_EQ(2U, h3.size());
  468. }
  469. } // namespace android