lib/tdb2: adapt unit tests to SAMBA environment.
[kai/samba-autobuild/.git] / lib / tdb2 / test / run-tdb_errorstr.c
1 #include "tdb2-source.h"
2 #include "tap-interface.h"
3
4 int main(int argc, char *argv[])
5 {
6         enum TDB_ERROR err;
7         plan_tests(TDB_ERR_RDONLY*-1 + 2);
8
9         for (err = TDB_SUCCESS; err >= TDB_ERR_RDONLY; err--) {
10                 switch (err) {
11                 case TDB_SUCCESS:
12                         ok1(!strcmp(tdb_errorstr(err),
13                                     "Success"));
14                         break;
15                 case TDB_ERR_IO:
16                         ok1(!strcmp(tdb_errorstr(err),
17                                     "IO Error"));
18                         break;
19                 case TDB_ERR_LOCK:
20                         ok1(!strcmp(tdb_errorstr(err),
21                                     "Locking error"));
22                         break;
23                 case TDB_ERR_OOM:
24                         ok1(!strcmp(tdb_errorstr(err),
25                                     "Out of memory"));
26                         break;
27                 case TDB_ERR_EXISTS:
28                         ok1(!strcmp(tdb_errorstr(err),
29                                     "Record exists"));
30                         break;
31                 case TDB_ERR_EINVAL:
32                         ok1(!strcmp(tdb_errorstr(err),
33                                     "Invalid parameter"));
34                         break;
35                 case TDB_ERR_NOEXIST:
36                         ok1(!strcmp(tdb_errorstr(err),
37                                     "Record does not exist"));
38                         break;
39                 case TDB_ERR_RDONLY:
40                         ok1(!strcmp(tdb_errorstr(err),
41                                     "write not permitted"));
42                         break;
43                 case TDB_ERR_CORRUPT:
44                         ok1(!strcmp(tdb_errorstr(err),
45                                     "Corrupt database"));
46                         break;
47                 }
48         }
49         ok1(!strcmp(tdb_errorstr(err), "Invalid error code"));
50
51         return exit_status();
52 }