Add unit test for fisdir()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-06-06 17:42:31 +02:00
1 parent c22a6e64d9
commit 267465f3d2
5 files changed
+26 -34

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
*.log
*.trs
fisdir
fsendfile
lfile
makepath
+1
View File
@@ -2,6 +2,7 @@ EXTRA_DIST = check.h
CLEANFILES = *~ *.trs *.log
TESTS =
TESTS += fisdir
TESTS += fsendfile
TESTS += lfile
TESTS += makepath
+24
View File
@@ -0,0 +1,24 @@
#include "check.h"
int main(void)
{
size_t i = 0;
struct { char *file; int exist; } arr[] = {
{ "/etc/passwd", 0 },
{ "/etc/", 1 },
{ "/sbin/init", 0 },
{ "/dev/null", 0 },
{ "/dev/", 1 },
{ NULL, 0 },
};
for (i = 0; i < NELEMS(arr); i++) {
if (fisdir(arr[i].file) != arr[i].exist)
err(1, "Failed fisdir(%s)", arr[i].file ?: "NULL");
else
printf("fisdir() %-11s %-18s => OK!\n", arr[i].file ?: "NULL",
arr[i].exist ? "is a directory" : "is NOT a directory");
}
return 0;
}