src/test/util.h
author Tero Marttila <terom@fixme.fi>
Thu, 28 May 2009 01:17:36 +0300
branchnew-lib-errors
changeset 219 cefec18b8268
parent 168 a58ad50911fc
permissions -rw-r--r--
some of the lib/transport stuff compiles
#ifndef TEST_UTIL_H
#define TEST_UTIL_H

/**
 * @file
 *
 * General utility functions for tests
 */
#include <sys/types.h>

#define DUMP_STR_BUF 1024
#define DUMP_STR_COUNT 8

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

/**
 * As dump_strn(), with str as a NUL-terminated string
 */
const char *dump_str (const char *str); 

#endif