Changeset View
Changeset View
Standalone View
Standalone View
src/test/dbwrapper_tests.cpp
Show First 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | for (int x = 0x00; x < 256; ++x) { | ||||
BOOST_CHECK(dbw.Write(key, value)); | BOOST_CHECK(dbw.Write(key, value)); | ||||
} | } | ||||
} | } | ||||
// Check that creating an iterator creates a snapshot | // Check that creating an iterator creates a snapshot | ||||
std::unique_ptr<CDBIterator> it( | std::unique_ptr<CDBIterator> it( | ||||
const_cast<CDBWrapper &>(dbw).NewIterator()); | const_cast<CDBWrapper &>(dbw).NewIterator()); | ||||
for (int x = 0x00; x < 256; ++x) { | for (unsigned int x = 0x00; x < 256; ++x) { | ||||
uint8_t key = x; | uint8_t key = x; | ||||
uint32_t value = x * x; | uint32_t value = x * x; | ||||
if (x & 1) { | if (x & 1) { | ||||
BOOST_CHECK(dbw.Write(key, value)); | BOOST_CHECK(dbw.Write(key, value)); | ||||
} | } | ||||
} | } | ||||
for (int seek_start : {0x00, 0x80}) { | for (int seek_start : {0x00, 0x80}) { | ||||
it->Seek((uint8_t)seek_start); | it->Seek((uint8_t)seek_start); | ||||
for (int x = seek_start; x < 255; ++x) { | for (unsigned int x = seek_start; x < 255; ++x) { | ||||
uint8_t key; | uint8_t key; | ||||
uint32_t value; | uint32_t value; | ||||
BOOST_CHECK(it->Valid()); | BOOST_CHECK(it->Valid()); | ||||
// Avoid spurious errors about invalid iterator's key and value in | // Avoid spurious errors about invalid iterator's key and value in | ||||
// case of failure | // case of failure | ||||
if (!it->Valid()) break; | if (!it->Valid()) break; | ||||
BOOST_CHECK(it->GetKey(key)); | BOOST_CHECK(it->GetKey(key)); | ||||
if (x & 1) { | if (x & 1) { | ||||
▲ Show 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(iterator_string_ordering) { | ||||
} | } | ||||
std::unique_ptr<CDBIterator> it( | std::unique_ptr<CDBIterator> it( | ||||
const_cast<CDBWrapper &>(dbw).NewIterator()); | const_cast<CDBWrapper &>(dbw).NewIterator()); | ||||
for (int seek_start : {0, 5}) { | for (int seek_start : {0, 5}) { | ||||
snprintf(buf, sizeof(buf), "%d", seek_start); | snprintf(buf, sizeof(buf), "%d", seek_start); | ||||
StringContentsSerializer seek_key(buf); | StringContentsSerializer seek_key(buf); | ||||
it->Seek(seek_key); | it->Seek(seek_key); | ||||
for (int x = seek_start; x < 10; ++x) { | for (unsigned int x = seek_start; x < 10; ++x) { | ||||
for (int y = 0; y < 10; y++) { | for (int y = 0; y < 10; y++) { | ||||
snprintf(buf, sizeof(buf), "%d", x); | snprintf(buf, sizeof(buf), "%d", x); | ||||
std::string exp_key(buf); | std::string exp_key(buf); | ||||
for (int z = 0; z < y; z++) | for (int z = 0; z < y; z++) | ||||
exp_key += exp_key; | exp_key += exp_key; | ||||
StringContentsSerializer key; | StringContentsSerializer key; | ||||
uint32_t value; | uint32_t value; | ||||
BOOST_CHECK(it->Valid()); | BOOST_CHECK(it->Valid()); | ||||
Show All 15 Lines |