START_TEST(strsanitize_test)
{
	struct strsanitize_test {
		const char *string;
		const char *expected;
	} tests[] = {
		{ "foobar", "foobar" },
		{ "", "" },
		{ "%", "%%" },
		{ "%%%%", "%%%%%%%%" },
		{ "x %s", "x %%s" },
		{ "x %", "x %%" },
		{ "%sx", "%%sx" },
		{ "%s%s", "%%s%%s" },
		{ NULL, NULL },
	};

	for (struct strsanitize_test *t = tests; t->string; t++) {
		char *sanitized = str_sanitize(t->string);
		ck_assert_str_eq(sanitized, t->expected);
		free(sanitized);
	}
}
START_TEST(strsanitize_test)
{
	struct strsanitize_test {
		const char *string;
		const char *expected;
	} tests[] = {
		{ "foobar", "foobar" },
		{ "", "" },
		{ "%", "%%" },
		{ "%%%%", "%%%%%%%%" },
		{ "x %s", "x %%s" },
		{ "x %", "x %%" },
		{ "%sx", "%%sx" },
		{ "%s%s", "%%s%%s" },
		{ NULL, NULL },
	};

	for (struct strsanitize_test *t = tests; t->string; t++) {
		char *sanitized = str_sanitize(t->string);
		ck_assert_str_eq(sanitized, t->expected);
		free(sanitized);
	}
}