terom@168: #ifndef TEST_UTIL_H terom@168: #define TEST_UTIL_H terom@168: terom@168: /** terom@168: * @file terom@168: * terom@168: * General utility functions for tests terom@168: */ terom@168: #include terom@168: terom@168: #define DUMP_STR_BUF 1024 terom@168: #define DUMP_STR_COUNT 8 terom@168: terom@168: /** terom@168: * This re-formats the given string to escape values, and returns a pointer to an internal static buffer. terom@168: * terom@168: * If len is given as >= 0, only the given number of chars will be dumped from str. terom@168: * terom@168: * The buffer cycles a bit, so the returned pointers remain valid across DUMP_STR_COUNT calls. terom@168: * terom@168: * The resulting string is truncated to DUMP_STR_BUF bytes, including the ending "...'\0". terom@168: * terom@168: * @param str the string to dump, should be NUL-terminated unless len is given terom@168: * @param len if negative, ignored, otherwise, only this many bytes are dumped from str terom@168: * @param return a pointer to a static buffer that remains valid across DUMP_STR_COUNT calls to this function terom@168: */ terom@168: const char *dump_strn (const char *str, ssize_t len); terom@168: terom@168: /** terom@168: * As dump_strn(), with str as a NUL-terminated string terom@168: */ terom@168: const char *dump_str (const char *str); terom@168: terom@168: #endif