MCPcopy Create free account
hub / github.com/SergeyMakeev/ExcaliburHash / ConstCorrectnessTest

Function ConstCorrectnessTest

ExcaliburHashTest03.cpp:134–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134void ConstCorrectnessTest(const Excalibur::HashTable<int, int>& ht)
135{
136 // this test is more of an API const correctness test (this code is expected to compile without errors)
137 uint32_t size = ht.size();
138 EXPECT_EQ(size, uint32_t(1));
139
140 uint32_t capacity = ht.capacity();
141 EXPECT_GE(capacity, uint32_t(1));
142
143 bool isEmpty = ht.empty();
144 EXPECT_FALSE(isEmpty);
145
146 bool shouldBeTrue = ht.has(1);
147 EXPECT_TRUE(shouldBeTrue);
148
149 bool shouldBeFalse = ht.has(-1);
150 EXPECT_FALSE(shouldBeFalse);
151
152 uint64_t sum = 0;
153
154 auto it1 = ht.find(1);
155 ASSERT_NE(it1, ht.iend());
156 sum += it1->first;
157 sum += it1->second;
158
159 // this should not compile!
160 /*
161 int& v = it1->second;
162 v = 7;
163 */
164
165 auto it2 = ht.find(-1);
166 EXPECT_EQ(it2, ht.iend());
167
168 for (auto it3 = ht.begin(); it3 != ht.end(); ++it3)
169 {
170 sum += *it3;
171 }
172
173 for (auto it4 = ht.vbegin(); it4 != ht.vend(); ++it4)
174 {
175 sum += *it4;
176 }
177
178 for (auto it5 = ht.ibegin(); it5 != ht.iend(); ++it5)
179 {
180 sum += it5->first;
181 sum += it5->second;
182
183 // this should not compile!
184 /*
185 int& v = it5->second;
186 v = 7;
187 */
188 }
189
190 for (int k : ht)
191 {

Callers 1

TESTFunction · 0.85

Calls 2

beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected