GUJIEJASON pirms 4 nedēļām
vecāks
revīzija
c97d7cee71
2 mainītis faili ar 31 papildinājumiem un 0 dzēšanām
  1. +5
    -0
      CMakeLists.txt
  2. +26
    -0
      test/db_test1.cc

+ 5
- 0
CMakeLists.txt Parādīt failu

@ -518,6 +518,11 @@ if(LEVELDB_INSTALL)
)
endif(LEVELDB_INSTALL)
add_executable(db_test1
"${PROJECT_SOURCE_DIR}/test/db_test1.cc"
)
target_link_libraries(db_test1 leveldb)
add_executable(db_test2
"${PROJECT_SOURCE_DIR}/test/db_test2.cc"

+ 26
- 0
test/db_test1.cc Parādīt failu

@ -0,0 +1,26 @@
#include "leveldb/db.h"
#include <iostream>
using namespace std;
using namespace leveldb;
int main() {
DB* db = nullptr;
Options op;
op.create_if_missing = true;
Status status = DB::Open(op, "testdb", &db);
assert(status.ok());
db->Put(WriteOptions(), "001", "leveldb");
string s;
db->Get(ReadOptions(), "001", &s);
cout<<s<<endl;
db->Put(WriteOptions(), "002", "world");
string s1;
db->Delete(WriteOptions(), "002");
db->Get(ReadOptions(), "002", &s1);
cout<<s1<<endl;
delete db;
return 0;
}

Notiek ielāde…
Atcelt
Saglabāt