summaryrefslogtreecommitdiffstats
path: root/test/strindex_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/strindex_test.c')
-rw-r--r--test/strindex_test.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/test/strindex_test.c b/test/strindex_test.c
index 1dcd062..d19d77e 100644
--- a/test/strindex_test.c
+++ b/test/strindex_test.c
@@ -25,37 +25,35 @@ ZIX_LOG_FUNC(1, 2)
static int
test_fail(const char* fmt, ...)
{
- va_list args;
- va_start(args, fmt);
- fprintf(stderr, "error: ");
- vfprintf(stderr, fmt, args);
- va_end(args);
- return 1;
+ va_list args;
+ va_start(args, fmt);
+ fprintf(stderr, "error: ");
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ return 1;
}
int
main(void)
{
- const char* str = "BANANA";
- const size_t str_len = strlen(str);
- ZixStrindex* strindex = zix_strindex_new(str);
-
- for (size_t l = 1; l <= str_len; ++l) {
- for (size_t i = 0; i < str_len - l; ++i) {
- char* match = NULL;
- ZixStatus ret = zix_strindex_find(strindex, str + i, &match);
- if (ret) {
- return test_fail("No match for substring at %zu length %zu\n",
- i, l);
- }
-
- if (strncmp(str + i, match, l)) {
- return test_fail("Bad match for substring at %zu length %zu\n",
- i, l);
- }
- }
- }
-
- zix_strindex_free(strindex);
- return 0;
+ const char* str = "BANANA";
+ const size_t str_len = strlen(str);
+ ZixStrindex* strindex = zix_strindex_new(str);
+
+ for (size_t l = 1; l <= str_len; ++l) {
+ for (size_t i = 0; i < str_len - l; ++i) {
+ char* match = NULL;
+ ZixStatus ret = zix_strindex_find(strindex, str + i, &match);
+ if (ret) {
+ return test_fail("No match for substring at %zu length %zu\n", i, l);
+ }
+
+ if (strncmp(str + i, match, l)) {
+ return test_fail("Bad match for substring at %zu length %zu\n", i, l);
+ }
+ }
+ }
+
+ zix_strindex_free(strindex);
+ return 0;
}