tdbTest.cpp 1001 字节
Newer Older
H
Hongze Cheng 已提交
1 2
#include "gtest/gtest.h"

H
more  
Hongze Cheng 已提交
3 4
#include "tdb.h"

H
Hongze Cheng 已提交
5
TEST(tdb_test, simple_test) {
H
Hongze Cheng 已提交
6 7 8 9
  TENV*     pEnv;
  TDB *     pDb1, *pDb2, *pDb3;
  pgsz_t    pgSize = 1024;
  cachesz_t cacheSize = 10240;
H
more  
Hongze Cheng 已提交
10

H
Hongze Cheng 已提交
11
  // ENV
H
Hongze Cheng 已提交
12 13 14 15 16 17 18 19 20
  GTEST_ASSERT_EQ(tdbEnvCreate(&pEnv, "./tdbtest"), 0);

  GTEST_ASSERT_EQ(tdbEnvSetCache(pEnv, pgSize, cacheSize), 0);

  GTEST_ASSERT_EQ(tdbEnvGetCacheSize(pEnv), cacheSize);

  GTEST_ASSERT_EQ(tdbEnvGetPageSize(pEnv), pgSize);

  GTEST_ASSERT_EQ(tdbEnvOpen(pEnv), 0);
H
Hongze Cheng 已提交
21

H
Hongze Cheng 已提交
22
#if 1
H
Hongze Cheng 已提交
23
  // DB
H
Hongze Cheng 已提交
24 25 26 27 28 29 30
  GTEST_ASSERT_EQ(tdbCreate(&pDb1), 0);

  GTEST_ASSERT_EQ(tdbSetKeyLen(pDb1, 8), 0);

  // GTEST_ASSERT_EQ(tdbSetValLen(pDb1, 3), 0);

  // GTEST_ASSERT_EQ(tdbSetDup(pDb1, 3), 0);
H
Hongze Cheng 已提交
31

H
Hongze Cheng 已提交
32 33 34
  GTEST_ASSERT_EQ(tdbOpen(pDb1, "db.db", "db1", pEnv), 0);

#if 0
H
Hongze Cheng 已提交
35 36 37 38 39 40 41
  // Insert

  // Query

  // Delete

  // Query
H
Hongze Cheng 已提交
42
#endif
H
Hongze Cheng 已提交
43

H
Hongze Cheng 已提交
44 45 46 47
  // GTEST_ASSERT_EQ(tdbOpen(&pDb2, "db.db", "db2", pEnv), 0);
  // GTEST_ASSERT_EQ(tdbOpen(&pDb3, "index.db", NULL, pEnv), 0);
  // tdbClose(pDb3);
  // tdbClose(pDb2);
H
Hongze Cheng 已提交
48
  tdbClose(pDb1);
H
Hongze Cheng 已提交
49
#endif
H
Hongze Cheng 已提交
50

H
Hongze Cheng 已提交
51
  tdbEnvClose(pEnv);
H
Hongze Cheng 已提交
52
}