Blame src/functional/dirname.c

nsz 7308b3
#include <stdlib.h>
nsz 7308b3
#include <string.h>
nsz 7308b3
#include <libgen.h>
nsz 5cde4d
#include "test.h"
nsz 7308b3
nsz 462b4f
#define T(path, want) \
nsz 462b4f
{ \
nsz ea9499
	char tmp[100]; \
nsz 462b4f
	char *got = dirname(strcpy(tmp, path)); \
nsz 462b4f
	if (strcmp(want, got) != 0) \
nsz 462b4f
		error("dirname(\"%s\") got \"%s\" want \"%s\"\n", path, got, want); \
nsz 7308b3
}
nsz 7308b3
nsz 462b4f
int main()
nsz 462b4f
{
nsz 7308b3
	if (strcmp(dirname(0), ".") != 0)
nsz 7308b3
		error("dirname(0) returned \"%s\"; expected \".\"\n", dirname(0));
nsz 462b4f
	T("", ".");
nsz 462b4f
	T("/usr/lib", "/usr");
nsz 462b4f
	T("/usr/", "/");
nsz 462b4f
	T("usr", ".");
nsz 462b4f
	T("usr/", ".");
nsz 462b4f
	T("/", "/");
nsz 462b4f
	T("///", "/");
nsz 462b4f
	T(".", ".");
nsz 462b4f
	T("..", ".");
nsz 462b4f
	return test_status;
nsz 7308b3
}