| 65 | } |
| 66 | |
| 67 | static int test_function(struct test_data *data, char *(*func)(char *input), |
| 68 | const char *funcname) |
| 69 | { |
| 70 | int failed = 0, i; |
| 71 | char buffer[1024]; |
| 72 | char *to; |
| 73 | |
| 74 | for (i = 0; data[i].to; i++) { |
| 75 | if (!data[i].from) |
| 76 | to = func(NULL); |
| 77 | else { |
| 78 | xsnprintf(buffer, sizeof(buffer), "%s", data[i].from); |
| 79 | to = func(buffer); |
| 80 | } |
| 81 | if (!strcmp(to, data[i].to)) |
| 82 | continue; |
| 83 | if (!data[i].alternative) |
| 84 | error("FAIL: %s(%s) => '%s' != '%s'", |
| 85 | funcname, data[i].from, to, data[i].to); |
| 86 | else if (!strcmp(to, data[i].alternative)) |
| 87 | continue; |
| 88 | else |
| 89 | error("FAIL: %s(%s) => '%s' != '%s', '%s'", |
| 90 | funcname, data[i].from, to, data[i].to, |
| 91 | data[i].alternative); |
| 92 | failed = 1; |
| 93 | } |
| 94 | return failed; |
| 95 | } |
| 96 | |
| 97 | static struct test_data basename_data[] = { |
| 98 | /* --- POSIX type paths --- */ |
no test coverage detected