Exemplo n.º 1
0
static int
test_segcat( newstr *s )
{
	char segment[]="0123456789";
	char *start=&(segment[2]), *end=&(segment[5]);
	int numstrings = 1000, i;
	int failed = 0;
	newstr t, u;

	newstr_init( &t );
	newstr_init( &u );

	newstr_empty( s );
	newstr_segcpy( s, start, start );
	if ( string_mismatch( s, 0, "" ) ) failed++;

	newstr_segcpy( &t, start, start );
	if ( string_mismatch( &t, 0, "" ) ) failed++;

	newstr_segcpy( &u, start, end );
	if ( string_mismatch( &u, 3, "234" ) ) failed++;

	newstr_empty( s );
	for ( i=0; i<numstrings; ++i )
		newstr_segcat( s, start, end );
	if ( inconsistent_len( s, 3*numstrings ) ) failed++;

	newstr_free( &t );
	newstr_free( &u );

	return failed;
}
Exemplo n.º 2
0
int
test_segcat( newstr *s )
{
	int failed = 0;
	int numstrings = 1000, i;
	char segment[]="0123456789";
	char *start=&(segment[2]), *end=&(segment[5]);
	newstr_empty( s );
	for ( i=0; i<numstrings; ++i ) {
		newstr_segcat( s, start, end );
	}
	failed = test_consistency( s, 3*numstrings, __FUNCTION__ );
	return failed;
}