MCPcopy Create free account
hub / github.com/crownengine/crown / test_hash_set

Function test_hash_set

src/core/unit_tests.cpp:235–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233}
234
235static void test_hash_set()
236{
237 memory_globals::init();
238 Allocator &a = default_allocator();
239 {
240 HashSet<s32> m(a);
241
242 ENSURE(hash_set::size(m) == 0);
243 ENSURE(!hash_set::has(m, 10));
244
245 for (s32 i = 0; i < 100; ++i)
246 hash_set::insert(m, i*i);
247 for (s32 i = 0; i < 100; ++i)
248 ENSURE(hash_set::has(m, i*i));
249
250 hash_set::remove(m, 5*5);
251 ENSURE(!hash_set::has(m, 5*5));
252
253 hash_set::remove(m, 80*80);
254 ENSURE(!hash_set::has(m, 80*80));
255
256 hash_set::remove(m, 40*40);
257 ENSURE(!hash_set::has(m, 40*40));
258
259 hash_set::clear(m);
260
261 for (s32 i = 0; i < 100; ++i)
262 ENSURE(!hash_set::has(m, i*i));
263 }
264 {
265 HashSet<s32> m(a);
266
267 for (s32 i = 0; i < 12; ++i) {
268 s32 key = 12 + i;
269 hash_set::insert(m, key);
270 hash_set::insert(m, i);
271 hash_set::remove(m, key);
272 }
273
274 ENSURE(hash_set::size(m) == 12);
275
276 for (s32 i = 0; i < 12; ++i)
277 ENSURE(hash_set::has(m, i));
278 }
279 {
280 HashSet<s32> ma(a);
281 HashSet<s32> mb(a);
282 hash_set::insert(ma, 0);
283 ma = mb;
284 }
285 {
286 DynamicString str(default_allocator());
287 str = "test";
288 HashSet<DynamicString> a(default_allocator());
289 HashSet<DynamicString> b(default_allocator());
290 hash_set::insert(a, str);
291 hash_set::insert(b, str);
292 a = b;

Callers

nothing calls this directly

Calls 6

initFunction · 0.70
clearFunction · 0.70
shutdownFunction · 0.70
sizeFunction · 0.50
hasFunction · 0.50
removeFunction · 0.50

Tested by

no test coverage detected