CCUnit  2.1
A C Unit Testing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Convert value to string
Assert

Make value to string. More...

Collaboration diagram for Convert value to string:

ccunit_assert_format_TYPE

snprintf format string for each types.

char * _ccunit_assert_format_char = "%c"
char * _ccunit_assert_format_u_char = "%c"
char * _ccunit_assert_format_int = "%d"
char * _ccunit_assert_format_u_int = "%u"
char * _ccunit_assert_format_short = "%hd"
char * _ccunit_assert_format_u_short = "%hu"
char * _ccunit_assert_format_long = "%ld"
char * _ccunit_assert_format_u_long = "%lu"
char * _ccunit_assert_format_float = "%f"
char * _ccunit_assert_format_double = "%f"
char * _ccunit_assert_format__ccunit_str_t = "%s"
char * _ccunit_assert_format__ccunit_ptr_t = "%p"

Value to string definitions

Make value to string.

Parameters:
TYPtype of value.
CAPACITYinitial size of string.
 DEF_VALUE_TO_STRING (char, 6)
 DEF_VALUE_TO_STRING (u_char, 6)
 DEF_VALUE_TO_STRING (int, 12)
 DEF_VALUE_TO_STRING (u_int, 12)
 DEF_VALUE_TO_STRING (short, 8)
 DEF_VALUE_TO_STRING (u_short, 8)
 DEF_VALUE_TO_STRING (long, 12)
 DEF_VALUE_TO_STRING (u_long, 12)
 DEF_VALUE_TO_STRING (float, 24)
 DEF_VALUE_TO_STRING (double, 24)
 DEF_VALUE_TO_STRING (_ccunit_str_t, 32)
 DEF_VALUE_TO_STRING (_ccunit_ptr_t, 24)
#define DEF_VALUE_TO_STRING(TYP, CAPACITY)

Detailed Description

Make value to string.


Macro Definition Documentation

#define DEF_VALUE_TO_STRING (   TYP,
  CAPACITY 
)
Value:
static char* TYP ## _to_string (TYP value) \
{ \
char* str = NULL; \
int require = 0; \
int capacity = CAPACITY; \
for (str = malloc (capacity); \
str != NULL; \
str = realloc (str, capacity)) \
{ \
require = snprintf (str, capacity, \
_ccunit_assert_format_ ## TYP, \
value); \
if (require < 0) \
capacity *= 2; \
else if (require < capacity) \
break; \
else \
capacity = require + 1; \
} \
return str; \
}

Function Documentation

DEF_VALUE_TO_STRING ( char  ,
 
)
DEF_VALUE_TO_STRING ( u_char  ,
 
)
DEF_VALUE_TO_STRING ( int  ,
12   
)
DEF_VALUE_TO_STRING ( u_int  ,
12   
)
DEF_VALUE_TO_STRING ( short  ,
 
)
DEF_VALUE_TO_STRING ( u_short  ,
 
)
DEF_VALUE_TO_STRING ( long  ,
12   
)
DEF_VALUE_TO_STRING ( u_long  ,
12   
)
DEF_VALUE_TO_STRING ( float  ,
24   
)
DEF_VALUE_TO_STRING ( double  ,
24   
)
DEF_VALUE_TO_STRING ( _ccunit_str_t  ,
32   
)
DEF_VALUE_TO_STRING ( _ccunit_ptr_t  ,
24   
)

Variable Documentation

char* _ccunit_assert_format__ccunit_ptr_t = "%p"
char* _ccunit_assert_format__ccunit_str_t = "%s"
char* _ccunit_assert_format_char = "%c"
char* _ccunit_assert_format_double = "%f"
char* _ccunit_assert_format_float = "%f"
char* _ccunit_assert_format_int = "%d"
char* _ccunit_assert_format_long = "%ld"
char* _ccunit_assert_format_short = "%hd"
char* _ccunit_assert_format_u_char = "%c"
char* _ccunit_assert_format_u_int = "%u"
char* _ccunit_assert_format_u_long = "%lu"
char* _ccunit_assert_format_u_short = "%hu"
SourceForge.jp hosts this site. Send comments to: CCUnit Developer