command_test.c : Add test for setting/getting SF_INSTRUMENT data.

This commit is contained in:
Erik de Castro Lopo 2005-10-23 18:25:40 +00:00
parent 705032cf79
commit 8952450542
2 changed files with 27 additions and 7 deletions

View File

@ -15,8 +15,8 @@
Add code to get and set SF_INSTRUMENT data.
* tests/command_test.* tests/Makefile.am
Start work on adding instrument tests.
command_test.c is no longer autogen generated.
Add test for set and getof SF_INSTRUMENT data.
The file command_test.c is no longer autogen generated.
2005-10-15 Erik de Castro Lopo <erikd AT mega-nerd DOT com>

View File

@ -599,17 +599,17 @@ truncate_test (const char *filename, int filetype)
static void
instrument_test (const char *filename, int filetype)
{ static const SF_INSTRUMENT write_inst =
{ static SF_INSTRUMENT write_inst =
{ 1, /* gain */
2, /* basenote */
3, 4,
5, 6,
2, /* loop_count */
{ { 1, 2, 3, 4 },
{ 2, 3, 4, 5 },
{ { 1, 2, 3, 4 },
{ 2, 3, 4, 5 },
}
} ;
/*-SF_INSTRUMENT read_inst ;-*/
SF_INSTRUMENT read_inst ;
SNDFILE *file ;
SF_INFO sfinfo ;
@ -621,15 +621,35 @@ instrument_test (const char *filename, int filetype)
file = test_open_file_or_die (filename, SFM_WRITE, &sfinfo, SF_TRUE, __LINE__) ;
test_write_double_or_die (file, 0, double_data, BUFFER_LEN, __LINE__) ;
if (sf_command (file, SFC_SET_INSTRUMENT, &write_inst, sizeof (write_inst)) == SF_FALSE)
{ printf ("\n\nLine %d : sf_command (SFC_SET_INSTRUMENT) failed.\n\n", __LINE__) ;
exit (1) ;
} ;
sf_close (file) ;
memset (&read_inst, 0, sizeof (read_inst)) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ;
if (sf_command (file, SFC_GET_INSTRUMENT, &read_inst, sizeof (read_inst)) == SF_FALSE)
{ printf ("\n\nLine %d : sf_command (SFC_GET_INSTRUMENT) failed.\n\n", __LINE__) ;
/*-exit (1) ;-*/
return ;
} ;
sf_close (file) ;
if (memcmp (&write_inst, &read_inst, sizeof (write_inst)) != 0)
{ printf ("\n\nLine %d : instrument comparison failed.\n\n", __LINE__) ;
/*-exit (1) ;-*/
return ;
} ;
unlink (filename) ;
puts ("ok") ;
} /* instrument_test */
/*
** Do not edit or modify anything in this comment block.
** The following line is a file identity tag for the GNU Arch
** The following line is a file identity tag for the GNU Arch
** revision control system.
**
** arch-tag: 59e5d452-8dae-45aa-99aa-b78dc0deba1c