math/gen: yet another little decimal formatting tool
[libc-test.git] / src / functional / dirname.c
blob766d46778fd84e7e0074221a5cfb399eca75fc16
1 #include <stdlib.h>
2 #include <string.h>
3 #include <libgen.h>
4 #include "test.h"
6 #define T(path, want) \
7 { \
8 char tmp[100]; \
9 char *got = dirname(strcpy(tmp, path)); \
10 if (strcmp(want, got) != 0) \
11 t_error("dirname(\"%s\") got \"%s\" want \"%s\"\n", path, got, want); \
14 int main()
16 if (strcmp(dirname(0), ".") != 0)
17 t_error("dirname(0) returned \"%s\"; expected \".\"\n", dirname(0));
18 T("", ".");
19 T("/usr/lib", "/usr");
20 T("/usr/", "/");
21 T("usr", ".");
22 T("usr/", ".");
23 T("/", "/");
24 T("///", "/");
25 T(".", ".");
26 T("..", ".");
27 return t_status;