tdb2: Make tdb1 share tdb_store flags, struct tdb_data and TDB_MAGIC_FOOD.
[Samba.git] / lib / tdb2 / test / run-tdb1-zero-append.c
blob1ecab54ce41465c748bcf26152753bbe304d36a7
1 #include "tdb2-source.h"
2 #include <ccan/tap/tap.h>
3 #include <stdlib.h>
4 #include <err.h>
5 #include "tdb1-logging.h"
7 int main(int argc, char *argv[])
9 struct tdb1_context *tdb;
10 TDB_DATA key, data;
12 plan_tests(4);
13 tdb = tdb1_open_ex(NULL, 1024, TDB1_INTERNAL, O_CREAT|O_TRUNC|O_RDWR,
14 0600, &taplogctx, NULL);
15 ok1(tdb);
17 /* Tickle bug on appending zero length buffer to zero length buffer. */
18 key.dsize = strlen("hi");
19 key.dptr = (void *)"hi";
20 data.dptr = (void *)"world";
21 data.dsize = 0;
23 ok1(tdb1_append(tdb, key, data) == 0);
24 ok1(tdb1_append(tdb, key, data) == 0);
25 data = tdb1_fetch(tdb, key);
26 ok1(data.dsize == 0);
27 free(data.dptr);
28 tdb1_close(tdb);
30 return exit_status();