1 #include "../common/tdb_private.h"
2 #include "../common/io.c"
3 #include "../common/tdb.c"
4 #include "../common/lock.c"
5 #include "../common/freelist.c"
6 #include "../common/traverse.c"
7 #include "../common/transaction.c"
8 #include "../common/error.c"
9 #include "../common/open.c"
10 #include "../common/check.c"
11 #include "../common/hash.c"
12 #include "tap-interface.h"
16 int main(int argc
, char *argv
[])
18 struct tdb_context
*tdb
;
22 tdb
= tdb_open_ex("run.tdb", 1024, TDB_CLEAR_IF_FIRST
,
23 O_CREAT
|O_TRUNC
|O_RDWR
, 0600, &taplogctx
, NULL
);
26 key
.dsize
= strlen("hi");
27 key
.dptr
= (void *)"hi";
28 data
.dsize
= strlen("world");
29 data
.dptr
= (void *)"world";
31 ok1(tdb_store(tdb
, key
, data
, TDB_MODIFY
) < 0);
32 ok1(tdb_error(tdb
) == TDB_ERR_NOEXIST
);
33 ok1(tdb_store(tdb
, key
, data
, TDB_INSERT
) == 0);
34 ok1(tdb_store(tdb
, key
, data
, TDB_INSERT
) < 0);
35 ok1(tdb_error(tdb
) == TDB_ERR_EXISTS
);
36 ok1(tdb_store(tdb
, key
, data
, TDB_MODIFY
) == 0);
38 data
= tdb_fetch(tdb
, key
);
39 ok1(data
.dsize
== strlen("world"));
40 ok1(memcmp(data
.dptr
, "world", strlen("world")) == 0);
44 data
= tdb_fetch(tdb
, key
);
45 ok1(data
.dptr
== NULL
);