Commit 8da77101 authored by Rich Prohaska's avatar Rich Prohaska

test the Dbc::del method. closes #227

git-svn-id: file:///svn/tokudb@1397 c7de825b-a66e-492c-adef-691d508d4ae1
parent 1f89623c
......@@ -114,9 +114,34 @@ void test_db_exceptions (void) {
}
void test_dbc_exceptions () {
DbEnv env(0);
TC(env.open(".", DB_INIT_MPOOL | DB_CREATE | DB_PRIVATE , 0777), 0);
Db db(&env, 0);
unlink("foo.db");
TC(db.open(0, "foo.db", 0, DB_BTREE, DB_CREATE, 0777), 0);
for (int k = 1; k<4; k++) {
Dbt key(&k, sizeof k);
Dbt val(&k, sizeof k);
TC(db.put(0, &key, &val, 0), 0);
}
Dbc *curs;
TC(db.cursor(0, &curs, 0), 0);
Dbt key; key.set_flags(DB_DBT_MALLOC);
Dbt val; val.set_flags(DB_DBT_MALLOC);
TC(curs->get(&key, &val, DB_FIRST), 0);
free(key.get_data());
free(val.get_data());
TC(curs->del(DB_DELETE_ANY), 0);
TC(curs->get(&key, &val, DB_CURRENT), DB_KEYEMPTY);
TC(curs->del(DB_DELETE_ANY), DB_NOTFOUND);
curs->close(); // no deleting cursors.
}
int main(int argc, char *argv[]) {
test_env_exceptions();
test_db_exceptions();
test_dbc_exceptions();
system("rm *.tokulog");
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment