From 6b36cfa23876708663d8fcddd40a431dddbf9905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurko=20Gospodneti=C4=87?= Date: Sun, 24 Jun 2012 00:00:35 +0000 Subject: [PATCH] Cleaned up and extended internal Boost Jam strings.c module unit tests. [SVN r79040] --- src/engine/strings.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/engine/strings.c b/src/engine/strings.c index 5fb894f6b..2ff979bbd 100644 --- a/src/engine/strings.c +++ b/src/engine/strings.c @@ -188,22 +188,31 @@ char string_back( string * self ) #ifndef NDEBUG void string_unit_test() { - string s[ 1 ]; - int i; - char buffer[ sizeof( s->opt ) * 2 + 2 ]; - int limit = sizeof( buffer ) > 254 ? 254 : sizeof( buffer ); - - string_new( s ); - - for ( i = 0; i < limit; ++i ) - string_push_back( s, (char)( i + 1 ) ); - - for ( i = 0; i < limit; ++i ) { - assert( i < s->size ); - assert( s->value[ i ] == (char)( i + 1 ) ); + string s[ 1 ]; + int i; + int const limit = sizeof( s->opt ) * 2 + 2; + string_new( s ); + assert( s->value == s->opt ); + for ( i = 0; i < limit; ++i ) + { + string_push_back( s, (char)( i + 1 ) ); + assert( s->size == i + 1 ); + } + assert( s->size == limit ); + assert( s->value != s->opt ); + for ( i = 0; i < limit; ++i ) + assert( s->value[ i ] == (char)( i + 1 ) ); + string_free( s ); } - string_free( s ); + { + char * const original = " \n\t\v Foo \r\n\v \tBar\n\n\r\r\t\n\v\t \t"; + string copy[ 1 ]; + string_copy( copy, original ); + assert( !strcmp( copy->value, original ) ); + assert( copy->size == strlen( original ) ); + string_free( copy ); + } } #endif