cannam@125: [+ AutoGen5 template c +] cannam@125: /* cannam@125: ** Copyright (C) 2010-2012 Erik de Castro Lopo cannam@125: ** cannam@125: ** This program is free software ; you can redistribute it and/or modify cannam@125: ** it under the terms of the GNU General Public License as published by cannam@125: ** the Free Software Foundation ; either version 2 of the License, or cannam@125: ** (at your option) any later version. cannam@125: ** cannam@125: ** This program is distributed in the hope that it will be useful, cannam@125: ** but WITHOUT ANY WARRANTY ; without even the implied warranty of cannam@125: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the cannam@125: ** GNU General Public License for more details. cannam@125: ** cannam@125: ** You should have received a copy of the GNU General Public License cannam@125: ** along with this program ; if not, write to the Free Software cannam@125: ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. cannam@125: */ cannam@125: cannam@125: #include "sfconfig.h" cannam@125: cannam@125: #include cannam@125: #include cannam@125: #include cannam@125: cannam@125: #include cannam@125: #include cannam@125: cannam@125: #if HAVE_UNISTD_H cannam@125: #include cannam@125: #endif cannam@125: cannam@125: #if (HAVE_DECL_S_IRGRP == 0) cannam@125: #include cannam@125: #endif cannam@125: cannam@125: #if (defined (WIN32) || defined (_WIN32)) cannam@125: #include cannam@125: #include cannam@125: #endif cannam@125: cannam@125: #include cannam@125: cannam@125: #include "utils.h" cannam@125: cannam@125: [+ FOR data_type cannam@125: +]static void rdwr_[+ (get "name") +]_test (const char *filename) ; cannam@125: [+ ENDFOR data_type cannam@125: +] cannam@125: cannam@125: int cannam@125: main (void) cannam@125: { cannam@125: rdwr_short_test ("rdwr_short.wav") ; cannam@125: rdwr_int_test ("rdwr_int.wav") ; cannam@125: rdwr_float_test ("rdwr_float.wav") ; cannam@125: rdwr_double_test ("rdwr_double.wav") ; cannam@125: rdwr_raw_test ("rdwr_raw.wav") ; cannam@125: cannam@125: return 0 ; cannam@125: } /* main */ cannam@125: cannam@125: cannam@125: /*============================================================================================ cannam@125: ** Here are the test functions. cannam@125: */ cannam@125: cannam@125: [+ FOR data_type cannam@125: +]static void cannam@125: rdwr_[+ (get "name") +]_test (const char *filename) cannam@125: { SNDFILE *file ; cannam@125: SF_INFO sfinfo ; cannam@125: sf_count_t frames ; cannam@125: [+ (get "type") +] buffer [160] ; cannam@125: cannam@125: print_test_name ("rdwr_[+ (get "name") +]_test", filename) ; cannam@125: cannam@125: memset (buffer, 0, sizeof (buffer)) ; cannam@125: cannam@125: /* Create sound file with no data. */ cannam@125: sfinfo.format = SF_FORMAT_WAV | [+ (get "format") +] ; cannam@125: sfinfo.samplerate = 16000 ; cannam@125: sfinfo.channels = 1 ; cannam@125: cannam@125: unlink (filename) ; cannam@125: cannam@125: frames = ARRAY_LEN (buffer) ; cannam@125: cannam@125: /* Open again for read/write. */ cannam@125: file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ; cannam@125: cannam@125: test_write_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ; cannam@125: cannam@125: test_read_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ; cannam@125: cannam@125: sf_close (file) ; cannam@125: unlink (filename) ; cannam@125: cannam@125: puts ("ok") ; cannam@125: return ; cannam@125: } /* rdwr_[+ (get "name") +]_test */ cannam@125: cannam@125: [+ ENDFOR data_type cannam@125: +] cannam@125: