START_TEST(basename_test)
{
	struct test {
		const char *path;
		const char *expected;
	} tests[] = {
		{ "a", "a" },
		{ "foo.c", "foo.c" },
		{ "foo", "foo" },
		{ "/path/to/foo.h", "foo.h" },
		{ "../bar.foo", "bar.foo" },
		{ "./bar.foo.baz", "bar.foo.baz" },
		{ "./", NULL },
		{ "/", NULL },
		{ "/bar/", NULL },
		{ "/bar", "bar" },
		{ "", NULL },
	};
	struct test *t;

	ARRAY_FOR_EACH(tests, t) {
		const char *result = safe_basename(t->path);
		if (t->expected == NULL)
			ck_assert(result == NULL);
		else
			ck_assert_str_eq(result, t->expected);
	}
}
START_TEST(basename_test)
{
	struct test {
		const char *path;
		const char *expected;
	} tests[] = {
		{ "a", "a" },
		{ "foo.c", "foo.c" },
		{ "foo", "foo" },
		{ "/path/to/foo.h", "foo.h" },
		{ "../bar.foo", "bar.foo" },
		{ "./bar.foo.baz", "bar.foo.baz" },
		{ "./", NULL },
		{ "/", NULL },
		{ "/bar/", NULL },
		{ "/bar", "bar" },
		{ "", NULL },
	};
	struct test *t;

	ARRAY_FOR_EACH(tests, t) {
		const char *result = safe_basename(t->path);
		if (t->expected == NULL)
			ck_assert(result == NULL);
		else
			ck_assert_str_eq(result, t->expected);
	}
}