add test for strftime
[libc-test.git] / src / functional / basename.c
blob96a470e117a4d94cdecca8c15510a104282f5549
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 = basename(strcpy(tmp, path)); \
10 if (strcmp(want, got) != 0) \
11 t_error("basename(\"%s\") got \"%s\" want \"%s\"\n", path, got, want); \
14 int main()
16 if (strcmp(basename(0), ".") != 0)
17 t_error("basename(0) returned \"%s\"; expected \".\"\n", basename(0));
18 T("", ".");
19 T("/usr/lib", "lib");
20 T("/usr/", "usr");
21 T("usr/", "usr");
22 T("/", "/");
23 T("///", "/");
24 T("//usr//lib//", "lib");
25 T(".", ".");
26 T("..", "..");
27 return t_status;