annotate src/libsndfile-1.0.25/tests/rdwr_test.tpl @ 88:fe7c3a0b0259

Add some MinGW builds
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 20 Mar 2013 13:49:36 +0000
parents 545efbb81310
children
rev   line source
cannam@85 1 [+ AutoGen5 template c +]
cannam@85 2 /*
cannam@85 3 ** Copyright (C) 2010-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
cannam@85 4 **
cannam@85 5 ** This program is free software ; you can redistribute it and/or modify
cannam@85 6 ** it under the terms of the GNU General Public License as published by
cannam@85 7 ** the Free Software Foundation ; either version 2 of the License, or
cannam@85 8 ** (at your option) any later version.
cannam@85 9 **
cannam@85 10 ** This program is distributed in the hope that it will be useful,
cannam@85 11 ** but WITHOUT ANY WARRANTY ; without even the implied warranty of
cannam@85 12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@85 13 ** GNU General Public License for more details.
cannam@85 14 **
cannam@85 15 ** You should have received a copy of the GNU General Public License
cannam@85 16 ** along with this program ; if not, write to the Free Software
cannam@85 17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cannam@85 18 */
cannam@85 19
cannam@85 20 #include "sfconfig.h"
cannam@85 21
cannam@85 22 #include <stdio.h>
cannam@85 23 #include <stdlib.h>
cannam@85 24 #include <string.h>
cannam@85 25
cannam@85 26 #include <sys/stat.h>
cannam@85 27 #include <math.h>
cannam@85 28
cannam@85 29 #if HAVE_UNISTD_H
cannam@85 30 #include <unistd.h>
cannam@85 31 #endif
cannam@85 32
cannam@85 33 #if (HAVE_DECL_S_IRGRP == 0)
cannam@85 34 #include <sf_unistd.h>
cannam@85 35 #endif
cannam@85 36
cannam@85 37 #if (defined (WIN32) || defined (_WIN32))
cannam@85 38 #include <io.h>
cannam@85 39 #include <direct.h>
cannam@85 40 #endif
cannam@85 41
cannam@85 42 #include <sndfile.h>
cannam@85 43
cannam@85 44 #include "utils.h"
cannam@85 45
cannam@85 46 [+ FOR data_type
cannam@85 47 +]static void rdwr_[+ (get "name") +]_test (const char *filename) ;
cannam@85 48 [+ ENDFOR data_type
cannam@85 49 +]
cannam@85 50
cannam@85 51 int
cannam@85 52 main (void)
cannam@85 53 {
cannam@85 54 rdwr_short_test ("rdwr_short.wav") ;
cannam@85 55 rdwr_int_test ("rdwr_int.wav") ;
cannam@85 56 rdwr_float_test ("rdwr_float.wav") ;
cannam@85 57 rdwr_double_test ("rdwr_double.wav") ;
cannam@85 58 rdwr_raw_test ("rdwr_raw.wav") ;
cannam@85 59
cannam@85 60 return 0 ;
cannam@85 61 } /* main */
cannam@85 62
cannam@85 63
cannam@85 64 /*============================================================================================
cannam@85 65 ** Here are the test functions.
cannam@85 66 */
cannam@85 67
cannam@85 68 [+ FOR data_type
cannam@85 69 +]static void
cannam@85 70 rdwr_[+ (get "name") +]_test (const char *filename)
cannam@85 71 { SNDFILE *file ;
cannam@85 72 SF_INFO sfinfo ;
cannam@85 73 sf_count_t frames ;
cannam@85 74 [+ (get "type") +] buffer [160] ;
cannam@85 75
cannam@85 76 print_test_name ("rdwr_[+ (get "name") +]_test", filename) ;
cannam@85 77
cannam@85 78 memset (buffer, 0, sizeof (buffer)) ;
cannam@85 79
cannam@85 80 /* Create sound file with no data. */
cannam@85 81 sfinfo.format = SF_FORMAT_WAV | [+ (get "format") +] ;
cannam@85 82 sfinfo.samplerate = 16000 ;
cannam@85 83 sfinfo.channels = 1 ;
cannam@85 84
cannam@85 85 unlink (filename) ;
cannam@85 86
cannam@85 87 frames = ARRAY_LEN (buffer) ;
cannam@85 88
cannam@85 89 /* Open again for read/write. */
cannam@85 90 file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_TRUE, __LINE__) ;
cannam@85 91
cannam@85 92 test_write_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ;
cannam@85 93
cannam@85 94 test_read_[+ (get "name") +]_or_die (file, 0, buffer, frames, __LINE__) ;
cannam@85 95
cannam@85 96 sf_close (file) ;
cannam@85 97 unlink (filename) ;
cannam@85 98
cannam@85 99 puts ("ok") ;
cannam@85 100 return ;
cannam@85 101 } /* rdwr_[+ (get "name") +]_test */
cannam@85 102
cannam@85 103 [+ ENDFOR data_type
cannam@85 104 +]
cannam@85 105