1#ifndef __cxxtest__ValueTraits_cpp__
2#define __cxxtest__ValueTraits_cpp__
15 return (
char)(
'0' + digit);
16 if ( digit <= 10 +
'Z' -
'A' )
17 return (
char)(
'A' + digit - 10);
32 while ( (*dst = *src) !=
'\0' ) {
42 while ( (c = *s1++) == *s2++ )
61 if ( c >= 32 && c <= 127 ) {
73 return numberToString( c,
s + 2, 16UL );
82 char *
bytesToString(
const unsigned char *bytes,
unsigned numBytes,
unsigned maxBytes,
char *
s )
84 bool truncate = (numBytes > maxBytes);
89 for (
unsigned i = 0;
i < numBytes; ++
i, ++ bytes )
96#ifndef CXXTEST_USER_VALUE_TRAITS
97 unsigned ValueTraits<const double>::requiredDigitsOnLeft(
double t )
100 for ( t = (t < 0.0) ? -t : t; t > 1.0; t /= BASE )
105 char *ValueTraits<const double>::doNegative(
double &t )
111 return _asString + 1;
114 void ValueTraits<const double>::hugeNumber(
double t )
116 char *
s = doNegative( t );
117 s = doubleToString( t,
s, 0, 1 );
119 s = doubleToString( t,
s, 1, DIGITS_ON_RIGHT );
121 s = numberToString( requiredDigitsOnLeft( t ) - 1,
s );
124 void ValueTraits<const double>::normalNumber(
double t )
126 char *
s = doNegative( t );
127 s = doubleToString( t,
s );
129 for (
unsigned i = 0;
i < DIGITS_ON_RIGHT; ++
i )
130 s = numberToString( (
unsigned)(t *= BASE) % BASE,
s );
133 char *ValueTraits<const double>::doubleToString(
double t,
char *
s,
unsigned skip,
unsigned max )
135 return numberToString<double>( t,
s, BASE, skip,
max );
static int max(int a, int b)
bool stringsEqual(const char *s1, const char *s2)
const char * byteToHex(unsigned char byte)
char digitToChar(unsigned digit)
char * copyString(char *dst, const char *src)
char * charToString(unsigned long c, char *s)
char * bytesToString(const unsigned char *bytes, unsigned numBytes, unsigned maxBytes, char *s)