MCPcopy Create free account
hub / github.com/cruppstahl/upscaledb / multiDbInsertFindTest

Method multiDbInsertFindTest

unittests/env.cpp:312–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310 }
311
312 void multiDbInsertFindTest() {
313 const int MAX_DB = 5;
314 const int MAX_ITEMS = 300;
315 ups_db_t *db[MAX_DB];
316
317 BaseFixture bf;
318 bf.create_env(m_flags);
319
320 for (int i = 0; i < MAX_DB; i++) {
321 REQUIRE(0 == ups_env_create_db(bf.env, &db[i], (uint16_t)i + 1, 0, 0));
322
323 for (int j = 0; j < MAX_ITEMS; j++) {
324 int value = j * (i + 1);
325 ups_key_t key = ups_make_key(&value, sizeof(value));
326 ups_record_t rec = ups_make_record(&value, sizeof(value));
327 REQUIRE(0 == ups_db_insert(db[i], 0, &key, &rec, 0));
328 }
329 }
330
331 for (int i = 0; i < MAX_DB; i++) {
332 for (int j = 0; j < MAX_ITEMS; j++) {
333 int value = j * (i + 1);
334 ups_key_t key = ups_make_key(&value, sizeof(value));
335 ups_record_t rec = {0};
336
337 REQUIRE(0 == ups_db_find(db[i], 0, &key, &rec, 0));
338 REQUIRE(value == *(int *)rec.data);
339 REQUIRE((uint16_t)sizeof(value) == rec.size);
340 }
341 }
342
343 if (NOTSET(m_flags, UPS_IN_MEMORY)) {
344 for (int i = 0; i < MAX_DB; i++) {
345 REQUIRE(0 == ups_db_close(db[i], 0));
346 REQUIRE(0 == ups_env_open_db(bf.env, &db[i], (uint16_t)i + 1, 0, 0));
347 for (int j = 0; j < MAX_ITEMS; j++) {
348 int value = j * (i + 1);
349 ups_key_t key = ups_make_key(&value, sizeof(value));
350 ups_record_t rec = {0};
351
352 REQUIRE(0 == ups_db_find(db[i], 0, &key, &rec, 0));
353 REQUIRE(value == *(int *)rec.data);
354 REQUIRE((uint16_t)sizeof(value) == rec.size);
355 }
356 }
357 }
358 }
359
360 void multiDbInsertFindExtendedTest() {
361 const int MAX_DB = 5;

Callers 1

env.cppFile · 0.80

Calls 4

ups_db_insertFunction · 0.85
ups_db_findFunction · 0.85
ups_db_closeFunction · 0.85
create_envMethod · 0.45

Tested by

no test coverage detected