summaryrefslogtreecommitdiff
path: root/lib/mlibc/tests/posix/basename.c
blob: 260bf9083c6faf594db4fca8cb11f471b4d833c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <assert.h>
#include <libgen.h>
#include <string.h>

int main() {
	/* intentionally a macro: basename modifies its argument */
#define test_string(x, expectval) do {                         \
		char str[] = x;                                \
		assert(strcmp(basename(str), expectval) == 0); \
	} while (0)

	test_string("/usr/lib", "lib");
	test_string("/usr/", "usr");
	test_string("/", "/");
	test_string(".", ".");
	test_string("..", "..");
}