tests/command_test.c : Add test to detect if coding history is truncated.

This commit is contained in:
Erik de Castro Lopo 2008-10-28 06:56:16 +11:00
parent e6aaad25d3
commit 0c1e963eda
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2008-10-28 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/command_test.c
Add test to detect if coding history is truncated.
2008-10-27 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/command_test.c

View File

@ -990,7 +990,7 @@ check_coding_history_newlines (const char *filename)
snprintf (bc_write.origination_date, sizeof (bc_write.origination_date), "%d/%02d/%02d", 2006, 3, 30) ;
snprintf (bc_write.origination_time, sizeof (bc_write.origination_time), "%02d:%02d:%02d", 20, 27, 0) ;
snprintf (bc_write.umid, sizeof (bc_write.umid), "Some umid") ;
bc_write.coding_history_size = snprintf (bc_write.coding_history, sizeof (bc_write.coding_history), "This has\nUnix\nand\rMac OS9\rline endings.\n") ; ;
bc_write.coding_history_size = snprintf (bc_write.coding_history, sizeof (bc_write.coding_history), "This has\nUnix\nand\rMac OS9\rline endings.\nLast line") ; ;
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
if (sf_command (file, SFC_SET_BROADCAST_INFO, &bc_write, sizeof (bc_write)) == SF_FALSE)
@ -1016,6 +1016,11 @@ check_coding_history_newlines (const char *filename)
exit (1) ;
} ;
if (strstr (bc_read.coding_history, "Last line") == NULL)
{ printf ("\n\nLine %d : coding history truncated.\n\n", __LINE__) ;
exit (1) ;
} ;
for (k = 1 ; k < bc_read.coding_history_size ; k++)
{ if (bc_read.coding_history [k] == '\n' && bc_read.coding_history [k - 1] != '\r')
{ printf ("\n\nLine %d : '\\n' without '\\r' before.\n\n", __LINE__) ;