Ocean
Loading...
Searching...
No Matches
TestHashMap.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_TEST_TESTBASE_TEST_HASH_MAP_H
9#define META_OCEAN_TEST_TESTBASE_TEST_HASH_MAP_H
10
13
14namespace Ocean
15{
16
17namespace Test
18{
19
20namespace TestBase
21{
22
23/**
24 * This class implements a hash map test.
25 * @ingroup testbase
26 */
27class OCEAN_TEST_BASE_EXPORT TestHashMap
28{
29 public:
30
31 /**
32 * Tests the hash map functions.
33 * @param testDuration Number of seconds for each test, with range (0, infinity)
34 * @param selector Test selector for filtering sub-tests; default runs all tests
35 * @return True, if succeeded
36 */
37 static bool test(const double testDuration, const TestSelector& selector = TestSelector());
38
39 /**
40 * Tests the hash map for single values.
41 * @param testDuration Number of seconds for each test, with range (0, infinity)
42 * @return True, if succeeded
43 */
44 static bool testSingleIntegers(const double testDuration);
45
46 /**
47 * Tests the hash map for multiple values.
48 * @param testDuration Number of seconds for each test, with range (0, infinity)
49 * @return True, if succeeded
50 */
51 static bool testMultipleIntegers(const double testDuration);
52
53 /**
54 * Tests a hash map in which all keys share the same hash value.
55 * @return True, if succeeded
56 */
57 static bool testCollidingKeys();
58
59 protected:
60
61 /**
62 * Tests the hash map for a given number of elements with a given ratio of occupancy.
63 * @param number Number of elements to be tested
64 * @param occupancy Ratio of occupancy in percent
65 * @param testDuration Number of seconds for each test, with range (0, infinity)
66 * @return True, if succeeded
67 */
68 static bool testPerformanceSingleIntegers(const unsigned int number, const unsigned int occupancy, const double testDuration);
69
70 /**
71 * Validates the hash map with static capacity for a given number of elements with a given ratio of occupancy.
72 * @param number Number of elements to be tested
73 * @param occupancy Ratio of occupancy in percent
74 * @param testDuration Number of seconds for each test, with range (0, infinity)
75 * @return True, if succeeded
76 */
77 static bool validationStaticCapacitySingleIntegers(const unsigned int number, const unsigned int occupancy, const double testDuration);
78
79 /**
80 * Validates the hash map with dynamic capacity for a given number of elements with a given initial capacity.
81 * @param number Number of elements to be tested
82 * @param capacity The initial capacity
83 * @param testDuration Number of seconds for each test, with range (0, infinity)
84 * @return True, if succeeded
85 */
86 static bool validationDynamicCapacitySingleIntegers(const unsigned int number, const unsigned int capacity, const double testDuration);
87
88 /**
89 * Tests the hash map for a given number of elements with a given ratio of occupancy.
90 * @param number Number of elements to be tested
91 * @param occupancy Ratio of occupancy in percent
92 * @param testDuration Number of seconds for each test, with range (0, infinity)
93 * @return True, if succeeded
94 */
95 static bool testPerformanceMultipleIntegers(const unsigned int number, const unsigned int occupancy, const double testDuration);
96
97 /**
98 * Validates the hash map for a given number of elements with a given ratio of occupancy.
99 * @param number Number of elements to be tested
100 * @param occupancy Ratio of occupancy in percent
101 * @param testDuration Number of seconds for each test, with range (0, infinity)
102 * @return True, if succeeded
103 */
104 static bool validationMultipleIntegers(const unsigned int number, const unsigned int occupancy, const double testDuration);
105
106 /**
107 * Hash function mapping every key onto the same value, so that each element has to be probed past its predecessors.
108 * @param key The key to return the hash value for
109 * @return The constant hash value
110 */
111 static size_t constantHashFunction(const unsigned int& key);
112};
113
114}
115
116}
117
118}
119
120#endif // META_OCEAN_TEST_TESTBASE_TEST_HASH_MAP_H
This class implements a hash map test.
Definition TestHashMap.h:28
static bool validationMultipleIntegers(const unsigned int number, const unsigned int occupancy, const double testDuration)
Validates the hash map for a given number of elements with a given ratio of occupancy.
static bool testPerformanceSingleIntegers(const unsigned int number, const unsigned int occupancy, const double testDuration)
Tests the hash map for a given number of elements with a given ratio of occupancy.
static bool testMultipleIntegers(const double testDuration)
Tests the hash map for multiple values.
static size_t constantHashFunction(const unsigned int &key)
Hash function mapping every key onto the same value, so that each element has to be probed past its p...
static bool testSingleIntegers(const double testDuration)
Tests the hash map for single values.
static bool testPerformanceMultipleIntegers(const unsigned int number, const unsigned int occupancy, const double testDuration)
Tests the hash map for a given number of elements with a given ratio of occupancy.
static bool validationStaticCapacitySingleIntegers(const unsigned int number, const unsigned int occupancy, const double testDuration)
Validates the hash map with static capacity for a given number of elements with a given ratio of occu...
static bool validationDynamicCapacitySingleIntegers(const unsigned int number, const unsigned int capacity, const double testDuration)
Validates the hash map with dynamic capacity for a given number of elements with a given initial capa...
static bool test(const double testDuration, const TestSelector &selector=TestSelector())
Tests the hash map functions.
static bool testCollidingKeys()
Tests a hash map in which all keys share the same hash value.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
The namespace covering the entire Ocean framework.
Definition Accessor.h:15