mirror of
https://github.com/troglobit/libite.git
synced 2026-10-24 11:44:37 +00:00
Add unit test for fisdir()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
c22a6e64d9
commit
267465f3d2
5 files changed
+26
-34
No files matched your search
@@ -1,5 +1,6 @@
|
||||
*.log
|
||||
*.trs
|
||||
fisdir
|
||||
fsendfile
|
||||
lfile
|
||||
makepath
|
||||
|
||||
@@ -2,6 +2,7 @@ EXTRA_DIST = check.h
|
||||
CLEANFILES = *~ *.trs *.log
|
||||
|
||||
TESTS =
|
||||
TESTS += fisdir
|
||||
TESTS += fsendfile
|
||||
TESTS += lfile
|
||||
TESTS += makepath
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user