]> git.ozlabs.org Git - ccan/blob - ccan/tdb2/test/run-tdb_errorstr.c
tdb2: move open routines into a separate file (open.c)
[ccan] / ccan / tdb2 / test / run-tdb_errorstr.c
1 #include <ccan/tdb2/tdb.c>
2 #include <ccan/tdb2/open.c>
3 #include <ccan/tdb2/free.c>
4 #include <ccan/tdb2/lock.c>
5 #include <ccan/tdb2/io.c>
6 #include <ccan/tdb2/hash.c>
7 #include <ccan/tdb2/check.c>
8 #include <ccan/tdb2/transaction.c>
9 #include <ccan/tap/tap.h>
10
11 int main(int argc, char *argv[])
12 {
13         enum TDB_ERROR err;
14         plan_tests(TDB_ERR_RDONLY*-1 + 2);
15
16         for (err = TDB_SUCCESS; err >= TDB_ERR_RDONLY; err--) {
17                 switch (err) {
18                 case TDB_SUCCESS:
19                         ok1(!strcmp(tdb_errorstr(err),
20                                     "Success"));
21                         break;
22                 case TDB_ERR_IO:
23                         ok1(!strcmp(tdb_errorstr(err),
24                                     "IO Error"));
25                         break;
26                 case TDB_ERR_LOCK:
27                         ok1(!strcmp(tdb_errorstr(err),
28                                     "Locking error"));
29                         break;
30                 case TDB_ERR_OOM:
31                         ok1(!strcmp(tdb_errorstr(err),
32                                     "Out of memory"));
33                         break;
34                 case TDB_ERR_EXISTS:
35                         ok1(!strcmp(tdb_errorstr(err),
36                                     "Record exists"));
37                         break;
38                 case TDB_ERR_EINVAL:
39                         ok1(!strcmp(tdb_errorstr(err),
40                                     "Invalid parameter"));
41                         break;
42                 case TDB_ERR_NOEXIST:
43                         ok1(!strcmp(tdb_errorstr(err),
44                                     "Record does not exist"));
45                         break;
46                 case TDB_ERR_RDONLY:
47                         ok1(!strcmp(tdb_errorstr(err),
48                                     "write not permitted"));
49                         break;
50                 case TDB_ERR_CORRUPT:
51                         ok1(!strcmp(tdb_errorstr(err),
52                                     "Corrupt database"));
53                         break;
54                 }
55         }
56         ok1(!strcmp(tdb_errorstr(err), "Invalid error code"));
57
58         return exit_status();
59 }