annotate src/libsndfile-1.0.27/tests/rdwr_test.tpl @ 148:b4bfdf10c4b3

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