equal
deleted
inserted
replaced
|
1 #ifndef TEST_UTIL_H |
|
2 #define TEST_UTIL_H |
|
3 |
|
4 /** |
|
5 * @file |
|
6 * |
|
7 * General utility functions for tests |
|
8 */ |
|
9 #include <sys/types.h> |
|
10 |
|
11 #define DUMP_STR_BUF 1024 |
|
12 #define DUMP_STR_COUNT 8 |
|
13 |
|
14 /** |
|
15 * This re-formats the given string to escape values, and returns a pointer to an internal static buffer. |
|
16 * |
|
17 * If len is given as >= 0, only the given number of chars will be dumped from str. |
|
18 * |
|
19 * The buffer cycles a bit, so the returned pointers remain valid across DUMP_STR_COUNT calls. |
|
20 * |
|
21 * The resulting string is truncated to DUMP_STR_BUF bytes, including the ending "...'\0". |
|
22 * |
|
23 * @param str the string to dump, should be NUL-terminated unless len is given |
|
24 * @param len if negative, ignored, otherwise, only this many bytes are dumped from str |
|
25 * @param return a pointer to a static buffer that remains valid across DUMP_STR_COUNT calls to this function |
|
26 */ |
|
27 const char *dump_strn (const char *str, ssize_t len); |
|
28 |
|
29 /** |
|
30 * As dump_strn(), with str as a NUL-terminated string |
|
31 */ |
|
32 const char *dump_str (const char *str); |
|
33 |
|
34 #endif |