mirror of
https://github.com/troglobit/libite.git
synced 2026-10-08 16:24:31 +07:00
Add unit test for tree
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
+2
-1
@@ -1,4 +1,5 @@
|
||||
*.log
|
||||
*.trs
|
||||
pidfile
|
||||
makepath
|
||||
pidfile
|
||||
tree
|
||||
|
||||
+2
-1
@@ -2,8 +2,9 @@ EXTRA_DIST = check.h
|
||||
CLEANFILES = *~ *.trs *.log
|
||||
|
||||
TESTS =
|
||||
TESTS += pidfile
|
||||
TESTS += makepath
|
||||
TESTS += pidfile
|
||||
TESTS += tree
|
||||
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "check.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int result = 0;
|
||||
size_t i;
|
||||
struct { char *path; int fail; } arr[] = {
|
||||
{ "/etc/passwd", -1 },
|
||||
{ "/dev", 0 },
|
||||
{ "/sbin", 0 },
|
||||
};
|
||||
|
||||
for (i = 0; i < NELEMS(arr); i++) {
|
||||
if (tree(arr[i].path, 1) != arr[i].fail)
|
||||
result++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -120,30 +120,8 @@ int tree(char *path, int show_perms)
|
||||
return descend(path, show_perms, "");
|
||||
}
|
||||
|
||||
#ifdef UNITTEST
|
||||
#include "lite.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i, result = 0;
|
||||
struct { char *path; int fail; } arr[] = {
|
||||
{ "/etc/passwd", -1 },
|
||||
{ "/dev", 0 },
|
||||
{ "/sbin", 0 },
|
||||
};
|
||||
|
||||
for (i = 0; i < NELEMS(arr); i++) {
|
||||
if (tree(arr[i].path, 1) != arr[i].fail)
|
||||
result++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Local Variables:
|
||||
* compile-command: "make V=1 -f tree.mk"
|
||||
* indent-tabs-mode: t
|
||||
* c-file-style: "linux"
|
||||
* End:
|
||||
|
||||
Reference in New Issue
Block a user