in unittest/lib/kat.cpp [286:346]
BString katParseData( String data, LONGLONG line )
{
SIZE_T len = data.size();
BString result;
if( len > 1 && data[0] == '"' && data[len-1] == '"' )
{
result.assign( (BYTE *)&data[1], len-2 );
return result;
}
if( data.find( "repeat" ) == 0 )
{
SIZE_T iOpen = data.find( '(' );
SIZE_T iClose = data.find( ')' );
if( iOpen + 1 >= iClose || iOpen == data.npos || iClose == data.npos )
{
FATAL3( "Wrong parenthesis in repeat format, line %lld = %s", line, data.c_str() )
}
String repeatStr = strip( data.substr( iOpen + 1, iClose ) );
int repValue = atoi( repeatStr.c_str() );
BString repData = katParseData( strip( data.substr( iClose+1 ) ), line );
SIZE_T repLen = repData.size();
PBYTE pResult = new BYTE[ repLen * repValue ];
CHECK( pResult != NULL, "Out of memory" );
for( int i=0; i<repValue; i++ )
{
memcpy( pResult + i*repLen, repData.data(), repLen );
}
BString result( pResult, repLen * repValue );
delete [] pResult;
return result;
}
if( (len & 1) != 0 )
{
FATAL2( "Hex data has odd number of characters in line %lld", line );
}
result.assign( len/2, 0 );
for( SIZE_T i=0; i<len/2; i++ )
{
result[i] = hexToByte( &data[2*i], line );
}
return result;
}