mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 02:34:13 +08:00
mdbx-test: resolve minor MSVC /W4
warnings.
This commit is contained in:
parent
ac02490c97
commit
92ab17a644
@ -50,8 +50,8 @@ bool testcase_jitter::run() {
|
||||
check_dbi_error(MDBX_SUCCESS, "created-uncommitted");
|
||||
// note: here and below the 4-byte length keys and value are used
|
||||
// to be compatible with any Db-flags given from command line.
|
||||
MDBX_val key = {(void *)"k000", 4}, value = {(void *)"v001", 4};
|
||||
err = mdbx_put(txn_guard.get(), dbi, &key, &value, MDBX_UPSERT);
|
||||
MDBX_val k = {(void *)"k000", 4}, v = {(void *)"v001", 4};
|
||||
err = mdbx_put(txn_guard.get(), dbi, &k, &v, MDBX_UPSERT);
|
||||
if (err != MDBX_SUCCESS)
|
||||
failure_perror("jitter.put-1", err);
|
||||
txn_end(false);
|
||||
@ -69,16 +69,16 @@ bool testcase_jitter::run() {
|
||||
|
||||
// check after aborted txn
|
||||
txn_begin(false);
|
||||
value = {(void *)"v002", 4};
|
||||
err = mdbx_put(txn_guard.get(), dbi, &key, &value, MDBX_UPSERT);
|
||||
v = {(void *)"v002", 4};
|
||||
err = mdbx_put(txn_guard.get(), dbi, &k, &v, MDBX_UPSERT);
|
||||
if (err != MDBX_BAD_DBI)
|
||||
failure_perror("jitter.put-2", err);
|
||||
check_dbi_error(MDBX_BAD_DBI, "dropped-recreated-aborted");
|
||||
// restore DBI
|
||||
dbi = db_table_open(false);
|
||||
check_dbi_error(MDBX_SUCCESS, "dropped-recreated-aborted+reopened");
|
||||
value = {(void *)"v003", 4};
|
||||
err = mdbx_put(txn_guard.get(), dbi, &key, &value, MDBX_UPSERT);
|
||||
v = {(void *)"v003", 4};
|
||||
err = mdbx_put(txn_guard.get(), dbi, &k, &v, MDBX_UPSERT);
|
||||
if (err != MDBX_SUCCESS)
|
||||
failure_perror("jitter.put-3", err);
|
||||
txn_end(false);
|
||||
|
@ -199,21 +199,21 @@ void maker::setup(const config::actor_params_pod &actor, unsigned actor_id,
|
||||
assert(unsigned(MDBX_INTEGERKEY | MDBX_REVERSEKEY | MDBX_DUPSORT |
|
||||
MDBX_INTEGERDUP | MDBX_REVERSEDUP) < UINT16_MAX);
|
||||
#endif
|
||||
key_essentials.flags =
|
||||
key_essentials.flags = uint16_t(
|
||||
actor.table_flags &
|
||||
MDBX_db_flags_t(MDBX_INTEGERKEY | MDBX_REVERSEKEY | MDBX_DUPSORT);
|
||||
MDBX_db_flags_t(MDBX_INTEGERKEY | MDBX_REVERSEKEY | MDBX_DUPSORT));
|
||||
assert(actor.keylen_min <= UINT16_MAX);
|
||||
key_essentials.minlen = (uint16_t)actor.keylen_min;
|
||||
key_essentials.minlen = uint16_t(actor.keylen_min);
|
||||
assert(actor.keylen_max <= UINT32_MAX);
|
||||
key_essentials.maxlen =
|
||||
std::min(uint32_t(actor.keylen_max),
|
||||
uint32_t(mdbx_limits_keysize_max(
|
||||
actor.pagesize, MDBX_db_flags_t(key_essentials.flags))));
|
||||
|
||||
value_essentials.flags =
|
||||
actor.table_flags & MDBX_db_flags_t(MDBX_INTEGERDUP | MDBX_REVERSEDUP);
|
||||
value_essentials.flags = uint16_t(
|
||||
actor.table_flags & MDBX_db_flags_t(MDBX_INTEGERDUP | MDBX_REVERSEDUP));
|
||||
assert(actor.datalen_min <= UINT16_MAX);
|
||||
value_essentials.minlen = (uint16_t)actor.datalen_min;
|
||||
value_essentials.minlen = uint16_t(actor.datalen_min);
|
||||
assert(actor.datalen_max <= UINT32_MAX);
|
||||
value_essentials.maxlen =
|
||||
std::min(uint32_t(actor.datalen_max),
|
||||
|
31
test/test.cc
31
test/test.cc
@ -683,37 +683,36 @@ void testcase::verbose(const char *where, const char *stage,
|
||||
}
|
||||
}
|
||||
|
||||
void testcase::verbose(const char *where, const char *stage,
|
||||
const MDBX_val &key, const MDBX_val &data,
|
||||
int err) const {
|
||||
void testcase::verbose(const char *where, const char *stage, const MDBX_val &k,
|
||||
const MDBX_val &v, int err) const {
|
||||
char dump_key[32], dump_value[32];
|
||||
if (err != MDBX_SUCCESS && err != MDBX_RESULT_TRUE)
|
||||
log_verbose("speculum-%s: %s cursor {%d, %s}", where, stage, err,
|
||||
mdbx_strerror(err));
|
||||
else
|
||||
log_verbose("speculum-%s: %s cursor {%s, %s}", where, stage,
|
||||
mdbx_dump_val(&key, dump_key, sizeof(dump_key)),
|
||||
mdbx_dump_val(&data, dump_value, sizeof(dump_value)));
|
||||
mdbx_dump_val(&k, dump_key, sizeof(dump_key)),
|
||||
mdbx_dump_val(&v, dump_value, sizeof(dump_value)));
|
||||
}
|
||||
|
||||
void testcase::speculum_check_iterator(const char *where, const char *stage,
|
||||
const testcase::SET::const_iterator &it,
|
||||
const MDBX_val &key,
|
||||
const MDBX_val &data) const {
|
||||
const MDBX_val &k,
|
||||
const MDBX_val &v) const {
|
||||
char dump_key[32], dump_value[32];
|
||||
MDBX_val it_key = dataview2iov(it->first);
|
||||
MDBX_val it_data = dataview2iov(it->second);
|
||||
// log_verbose("speculum-%s: %s expect {%s, %s}", where, stage,
|
||||
// mdbx_dump_val(&it_key, dump_key, sizeof(dump_key)),
|
||||
// mdbx_dump_val(&it_data, dump_value, sizeof(dump_value)));
|
||||
if (!is_samedata(it_key, key))
|
||||
if (!is_samedata(it_key, k))
|
||||
failure("speculum-%s: %s key mismatch %s (must) != %s", where, stage,
|
||||
mdbx_dump_val(&it_key, dump_key, sizeof(dump_key)),
|
||||
mdbx_dump_val(&key, dump_value, sizeof(dump_value)));
|
||||
if (!is_samedata(it_data, data))
|
||||
mdbx_dump_val(&k, dump_value, sizeof(dump_value)));
|
||||
if (!is_samedata(it_data, v))
|
||||
failure("speculum-%s: %s data mismatch %s (must) != %s", where, stage,
|
||||
mdbx_dump_val(&it_data, dump_key, sizeof(dump_key)),
|
||||
mdbx_dump_val(&data, dump_value, sizeof(dump_value)));
|
||||
mdbx_dump_val(&v, dump_value, sizeof(dump_value)));
|
||||
}
|
||||
|
||||
#if SPECULUM_CURSORS
|
||||
@ -1208,16 +1207,16 @@ bool testcase::check_batch_get() {
|
||||
size_t i, n = 0;
|
||||
while (err == MDBX_SUCCESS) {
|
||||
for (i = 0; i < count; i += 2) {
|
||||
mdbx::slice key, value;
|
||||
int err2 = mdbx_cursor_get(cursor, &key, &value, MDBX_NEXT);
|
||||
mdbx::slice k, v;
|
||||
int err2 = mdbx_cursor_get(cursor, &k, &v, MDBX_NEXT);
|
||||
if (err2 != MDBX_SUCCESS)
|
||||
failure_perror("mdbx_cursor_open()", err2);
|
||||
if (key != pairs[i] || value != pairs[i + 1]) {
|
||||
if (k != pairs[i] || v != pairs[i + 1]) {
|
||||
log_error(
|
||||
"batch-get pair mismatch %zu/%zu: sequential{%s, %s} != "
|
||||
"batch{%s, %s}",
|
||||
n + i / 2, i, mdbx_dump_val(&key, dump_key, sizeof(dump_key)),
|
||||
mdbx_dump_val(&value, dump_value, sizeof(dump_value)),
|
||||
n + i / 2, i, mdbx_dump_val(&k, dump_key, sizeof(dump_key)),
|
||||
mdbx_dump_val(&v, dump_value, sizeof(dump_value)),
|
||||
mdbx_dump_val(&pairs[i], dump_key_batch, sizeof(dump_key_batch)),
|
||||
mdbx_dump_val(&pairs[i + 1], dump_value_batch,
|
||||
sizeof(dump_value_batch)));
|
||||
|
@ -216,12 +216,12 @@ protected:
|
||||
#endif /* SPECULUM_CURSORS */
|
||||
void speculum_check_iterator(const char *where, const char *stage,
|
||||
const testcase::SET::const_iterator &it,
|
||||
const MDBX_val &key, const MDBX_val &data) const;
|
||||
const MDBX_val &k, const MDBX_val &v) const;
|
||||
|
||||
void verbose(const char *where, const char *stage,
|
||||
const testcase::SET::const_iterator &it) const;
|
||||
void verbose(const char *where, const char *stage, const MDBX_val &key,
|
||||
const MDBX_val &data, int err = MDBX_SUCCESS) const;
|
||||
void verbose(const char *where, const char *stage, const MDBX_val &k,
|
||||
const MDBX_val &v, int err = MDBX_SUCCESS) const;
|
||||
|
||||
bool is_same(const Item &a, const Item &b) const;
|
||||
bool is_same(const SET::const_iterator &it, const MDBX_val &k,
|
||||
|
Loading…
x
Reference in New Issue
Block a user