summaryrefslogtreecommitdiff
path: root/issues/issue178_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'issues/issue178_test.cc')
-rw-r--r--issues/issue178_test.cc19
1 files changed, 8 insertions, 11 deletions
diff --git a/issues/issue178_test.cc b/issues/issue178_test.cc
index d50ffeb..5cd5862 100644
--- a/issues/issue178_test.cc
+++ b/issues/issue178_test.cc
@@ -7,9 +7,10 @@
#include <iostream>
#include <sstream>
+#include "gtest/gtest.h"
#include "leveldb/db.h"
#include "leveldb/write_batch.h"
-#include "util/testharness.h"
+#include "util/testutil.h"
namespace {
@@ -17,17 +18,15 @@ const int kNumKeys = 1100000;
std::string Key1(int i) {
char buf[100];
- snprintf(buf, sizeof(buf), "my_key_%d", i);
+ std::snprintf(buf, sizeof(buf), "my_key_%d", i);
return buf;
}
std::string Key2(int i) { return Key1(i) + "_xxx"; }
-class Issue178 {};
-
TEST(Issue178, Test) {
// Get rid of any state from an old run.
- std::string dbpath = leveldb::test::TmpDir() + "/leveldb_cbug_test";
+ std::string dbpath = testing::TempDir() + "leveldb_cbug_test";
DestroyDB(dbpath, leveldb::Options());
// Open database. Disable compression since it affects the creation
@@ -37,28 +36,28 @@ TEST(Issue178, Test) {
leveldb::Options db_options;
db_options.create_if_missing = true;
db_options.compression = leveldb::kNoCompression;
- ASSERT_OK(leveldb::DB::Open(db_options, dbpath, &db));
+ ASSERT_LEVELDB_OK(leveldb::DB::Open(db_options, dbpath, &db));
// create first key range
leveldb::WriteBatch batch;
for (size_t i = 0; i < kNumKeys; i++) {
batch.Put(Key1(i), "value for range 1 key");
}
- ASSERT_OK(db->Write(leveldb::WriteOptions(), &batch));
+ ASSERT_LEVELDB_OK(db->Write(leveldb::WriteOptions(), &batch));
// create second key range
batch.Clear();
for (size_t i = 0; i < kNumKeys; i++) {
batch.Put(Key2(i), "value for range 2 key");
}
- ASSERT_OK(db->Write(leveldb::WriteOptions(), &batch));
+ ASSERT_LEVELDB_OK(db->Write(leveldb::WriteOptions(), &batch));
// delete second key range
batch.Clear();
for (size_t i = 0; i < kNumKeys; i++) {
batch.Delete(Key2(i));
}
- ASSERT_OK(db->Write(leveldb::WriteOptions(), &batch));
+ ASSERT_LEVELDB_OK(db->Write(leveldb::WriteOptions(), &batch));
// compact database
std::string start_key = Key1(0);
@@ -84,5 +83,3 @@ TEST(Issue178, Test) {
}
} // anonymous namespace
-
-int main(int argc, char** argv) { return leveldb::test::RunAllTests(); }