| 9 | #define CHECKINVALID(pos, val, len) buf[pos] = val; testbytes(buf,len,UTF8PROC_ERROR_INVALIDUTF8,__LINE__) |
| 10 | |
| 11 | static void testbytes(utf8proc_uint8_t *buf, utf8proc_ssize_t len, utf8proc_ssize_t retval, int line) |
| 12 | { |
| 13 | utf8proc_int32_t out[16]; |
| 14 | utf8proc_ssize_t ret; |
| 15 | |
| 16 | /* Make a copy to ensure that memory is left uninitialized after "len" |
| 17 | * bytes. This way, Valgrind can detect overreads. |
| 18 | */ |
| 19 | utf8proc_uint8_t tmp[16]; |
| 20 | memcpy(tmp, buf, (unsigned long int)len); |
| 21 | |
| 22 | tests++; |
| 23 | if ((ret = utf8proc_iterate(tmp, len, out)) != retval) { |
| 24 | fprintf(stderr, "Failed (%d):", line); |
| 25 | for (utf8proc_ssize_t i = 0; i < len ; i++) { |
| 26 | fprintf(stderr, " 0x%02x", tmp[i]); |
| 27 | } |
| 28 | fprintf(stderr, " -> %zd\n", ret); |
| 29 | error++; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | int main(int argc, char **argv) |
| 34 | { |
nothing calls this directly
no test coverage detected