tdbTest.cpp 1.2 KB
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
  GTEST_ASSERT_EQ(tdbCreate(&pDb1), 0);

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

H
Hongze Cheng 已提交
28 29
  GTEST_ASSERT_EQ(tdbGetKeyLen(pDb1), 8);

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

H
Hongze Cheng 已提交
32 33 34 35 36 37 38
  // GTEST_ASSERT_EQ(tdbGetValLen(pDb1), 3);

  // GTEST_ASSERT_EQ(tdbSetDup(pDb1, 1), 0);

  // GTEST_ASSERT_EQ(tdbGetDup(pDb1), 1);

  // GTEST_ASSERT_EQ(tdbSetCmprFunc(pDb1, NULL), 0);
H
Hongze Cheng 已提交
39

H
Hongze Cheng 已提交
40 41 42
  GTEST_ASSERT_EQ(tdbOpen(pDb1, "db.db", "db1", pEnv), 0);

#if 0
H
Hongze Cheng 已提交
43 44 45 46 47 48 49
  // Insert

  // Query

  // Delete

  // Query
H
Hongze Cheng 已提交
50
#endif
H
Hongze Cheng 已提交
51

H
Hongze Cheng 已提交
52 53 54 55
  // 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 已提交
56
  tdbClose(pDb1);
H
Hongze Cheng 已提交
57
#endif
H
Hongze Cheng 已提交
58

H
Hongze Cheng 已提交
59
  tdbEnvClose(pEnv);
H
Hongze Cheng 已提交
60
}