1 #include "noerr/noerr.h"
3 #include "noerr/noerr.c"
10 int main(int argc, char *argv[])
12 /* tempnam(3) is generally a bad idea, but OK here. */
13 char *name = tempnam(NULL, "noerr");
18 /* Should fail to unlink. */
19 ok1(unlink(name) != 0);
22 /* This one should not set errno. */
24 ok1(unlink_noerr(name) == ENOENT);
27 /* Should fail to close. */
31 /* This one should not set errno. */
33 ok1(close_noerr(-1) == EBADF);
36 /* Test successful close/unlink doesn't hit errno either. */
37 fd = open(name, O_WRONLY|O_CREAT|O_EXCL, 0600);
41 ok1(close_noerr(fd) == 0);
45 ok1(unlink_noerr(name) == 0);
48 /* Test failing fclose */
49 fp = fopen(name, "wb");
52 ok1(fclose_noerr(fp) == EBADF);
54 /* Test successful fclose */
55 fp = fopen(name, "wb");
59 ok1(fclose_noerr(fp) == 0);