| 192 | |
| 193 | #ifndef NDEBUG |
| 194 | void string_unit_test() |
| 195 | { |
| 196 | { |
| 197 | string s[ 1 ]; |
| 198 | int i; |
| 199 | int const limit = sizeof( s->opt ) * 2 + 2; |
| 200 | string_new( s ); |
| 201 | assert( s->value == s->opt ); |
| 202 | for ( i = 0; i < limit; ++i ) |
| 203 | { |
| 204 | string_push_back( s, (char)( i + 1 ) ); |
| 205 | assert( s->size == i + 1 ); |
| 206 | } |
| 207 | assert( s->size == limit ); |
| 208 | assert( s->value != s->opt ); |
| 209 | for ( i = 0; i < limit; ++i ) |
| 210 | assert( s->value[ i ] == (char)( i + 1 ) ); |
| 211 | string_free( s ); |
| 212 | } |
| 213 | |
| 214 | { |
| 215 | char * const original = " \n\t\v Foo \r\n\v \tBar\n\n\r\r\t\n\v\t \t"; |
| 216 | string copy[ 1 ]; |
| 217 | string_copy( copy, original ); |
| 218 | assert( !strcmp( copy->value, original ) ); |
| 219 | assert( copy->size == strlen( original ) ); |
| 220 | string_free( copy ); |
| 221 | } |
| 222 | } |
| 223 | #endif |
no test coverage detected