Commit dff4b1d0 authored by Yoni Fogel's avatar Yoni Fogel

Added c++ functions:

DbEnv.set_data_dir, DbEnv.set_errpfx

Added tests for them.
Addresses #197

git-svn-id: file:///svn/tokudb@1290 c7de825b-a66e-492c-adef-691d508d4ae1
parent e9b07dba
...@@ -49,3 +49,12 @@ int DbEnv::txn_begin(DbTxn *parenttxn, DbTxn **txnp, u_int32_t flags) { ...@@ -49,3 +49,12 @@ int DbEnv::txn_begin(DbTxn *parenttxn, DbTxn **txnp, u_int32_t flags) {
} }
return ret; return ret;
} }
int DbEnv::set_data_dir(const char *dir) {
int ret = the_env->set_data_dir(the_env, dir);
return ret;
}
void DbEnv::set_errpfx(const char *errpfx) {
the_env->set_errpfx(the_env, errpfx);
}
...@@ -34,10 +34,21 @@ void test_db(void) { ...@@ -34,10 +34,21 @@ void test_db(void) {
r = db.remove("DoesNotExist.db", NULL, 0); assert(r == ENOENT); r = db.remove("DoesNotExist.db", NULL, 0); assert(r == ENOENT);
} }
void test_db_env(void) {
DbEnv dbenv(0);
int r;
r = dbenv.set_data_dir("."); assert(r == 0);
r = dbenv.set_data_dir(".."); assert(r == 0);
r = dbenv.set_data_dir(NULL); assert(r == EINVAL);
dbenv.set_errpfx("Prefix");
}
int main() int main()
{ {
test_dbt(); test_dbt();
test_db(); test_db();
test_db_env();
cout << "Hello World!" << endl; cout << "Welcome to C++ Programming" << endl; cout << "Hello World!" << endl; cout << "Welcome to C++ Programming" << endl;
return 0; return 0;
} }
...@@ -96,7 +96,8 @@ class DbEnv { ...@@ -96,7 +96,8 @@ class DbEnv {
int set_lk_max(u_int32_t); int set_lk_max(u_int32_t);
#endif #endif
int txn_begin(DbTxn *, DbTxn **, u_int32_t); int txn_begin(DbTxn *, DbTxn **, u_int32_t);
int set_data_dir(const char *dir);
void set_errpfx(const char *errpfx);
private: private:
DB_ENV *the_env; DB_ENV *the_env;
......
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