@ -384,6 +384,20 @@ static void test_index_of_column(void) {
assert ( sc_str_index_of_column ( " a bc d " , 1 , " " ) = = 2 ) ;
assert ( sc_str_index_of_column ( " a bc d " , 1 , " " ) = = 2 ) ;
}
}
static void test_remove_trailing_cr ( ) {
char s [ ] = " abc \r " ;
sc_str_remove_trailing_cr ( s , sizeof ( s ) - 1 ) ;
assert ( ! strcmp ( s , " abc " ) ) ;
char s2 [ ] = " def \r \r \r \r " ;
sc_str_remove_trailing_cr ( s2 , sizeof ( s2 ) - 1 ) ;
assert ( ! strcmp ( s2 , " def " ) ) ;
char s3 [ ] = " adb \r def \r " ;
sc_str_remove_trailing_cr ( s3 , sizeof ( s3 ) - 1 ) ;
assert ( ! strcmp ( s3 , " adb \r def " ) ) ;
}
int main ( int argc , char * argv [ ] ) {
int main ( int argc , char * argv [ ] ) {
( void ) argc ;
( void ) argc ;
( void ) argv ;
( void ) argv ;
@ -405,5 +419,6 @@ int main(int argc, char *argv[]) {
test_wrap_lines ( ) ;
test_wrap_lines ( ) ;
test_truncate ( ) ;
test_truncate ( ) ;
test_index_of_column ( ) ;
test_index_of_column ( ) ;
test_remove_trailing_cr ( ) ;
return 0 ;
return 0 ;
}
}