mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2024-11-23 09:59:54 +00:00
Move tests from open_fail_test.c to error_test.c and remove the former.
This commit is contained in:
parent
d7c919f121
commit
82ee6c7901
@ -1,3 +1,8 @@
|
||||
2007-10-23 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* tests/open_fail_test.c tests/error_test.c tests/Makefile.am
|
||||
Move tests from open_fail_test.c to error_test.c and remove the former.
|
||||
|
||||
2007-10-22 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* tests/scale_clip_test.(def|tpl)
|
||||
@ -6,6 +11,9 @@
|
||||
* doc/command.html
|
||||
Add docs for SFC_SET_INT_FLOAT_WRITE command.
|
||||
|
||||
* examples/sndfile-play.c tests/dft_cmp.c
|
||||
Fix gcc-4.2 warning messages.
|
||||
|
||||
2007-10-21 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
|
||||
* src/sndfile.h.in src/sndfile.c
|
||||
|
@ -10,7 +10,7 @@ noinst_PROGRAMS = sfversion floating_point_test write_read_test \
|
||||
lossy_comp_test error_test ulaw_test alaw_test dwvw_test \
|
||||
peak_chunk_test command_test stdin_test stdout_test stdio_test \
|
||||
pcm_test headerless_test pipe_test benchmark header_test misc_test \
|
||||
raw_test string_test open_fail_test multi_file_test dither_test \
|
||||
raw_test string_test multi_file_test dither_test \
|
||||
scale_clip_test win32_test fix_this aiff_rw_test virtual_io_test \
|
||||
locale_test largefile_test win32_ordinal_test $(CPP_TEST)
|
||||
|
||||
@ -100,9 +100,6 @@ string_test_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
dither_test_SOURCES = dither_test.c utils.c
|
||||
dither_test_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
open_fail_test_SOURCES = open_fail_test.c utils.c
|
||||
open_fail_test_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
multi_file_test_SOURCES = multi_file_test.c utils.c
|
||||
multi_file_test_LDADD = $(SNDFILEDIR)/libsndfile.la
|
||||
|
||||
@ -210,7 +207,6 @@ wav-tests: write_read_test lossy_comp_test peak_chunk_test header_test misc_test
|
||||
./misc_test wav
|
||||
./string_test wav
|
||||
./multi_file_test wav
|
||||
./open_fail_test wav
|
||||
@echo "----------------------------------------------------------------------"
|
||||
@echo " `./sfversion` passed tests on WAV files."
|
||||
@echo "----------------------------------------------------------------------"
|
||||
|
@ -33,17 +33,6 @@
|
||||
#define BUFFER_SIZE (1<<15)
|
||||
#define SHORT_BUFFER (256)
|
||||
|
||||
static void error_number_test (void) ;
|
||||
static void error_value_test (void) ;
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ error_number_test () ;
|
||||
error_value_test () ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
static void
|
||||
error_number_test (void)
|
||||
{ const char *noerror, *errstr ;
|
||||
@ -104,10 +93,90 @@ error_value_test (void)
|
||||
return ;
|
||||
} /* error_value_test */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 799eba74-b505-49d9-89a6-22a7f51a31b4
|
||||
*/
|
||||
static void
|
||||
no_file_test (const char * filename)
|
||||
{ SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
print_test_name (__func__, filename) ;
|
||||
|
||||
unlink (filename) ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
|
||||
|
||||
exit_if_true (sndfile != NULL, "\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
|
||||
|
||||
unlink (filename) ;
|
||||
puts ("ok") ;
|
||||
} /* no_file_test */
|
||||
|
||||
static void
|
||||
zero_length_test (const char *filename)
|
||||
{ SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
FILE *file ;
|
||||
|
||||
print_test_name (__func__, filename) ;
|
||||
|
||||
/* Create a zero length file. */
|
||||
file = fopen (filename, "w") ;
|
||||
exit_if_true (file == NULL, "\n\nLine %d : fopen ('%s') failed.\n", __LINE__, filename) ;
|
||||
fclose (file) ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
|
||||
|
||||
exit_if_true (sndfile != NULL, "\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
|
||||
|
||||
exit_if_true (0 && sf_error (NULL) != SF_ERR_UNRECOGNISED_FORMAT,
|
||||
"\n\nLine %3d : Error : %s\n should be : %s\n", __LINE__,
|
||||
sf_strerror (NULL), sf_error_number (SF_ERR_UNRECOGNISED_FORMAT)) ;
|
||||
|
||||
unlink (filename) ;
|
||||
puts ("ok") ;
|
||||
} /* zero_length_test */
|
||||
|
||||
static void
|
||||
bad_wav_test (const char * filename)
|
||||
{ SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
FILE *file ;
|
||||
const char data [] = "RIFF WAVEfmt " ;
|
||||
|
||||
print_test_name (__func__, filename) ;
|
||||
|
||||
if ((file = fopen (filename, "w")) == NULL)
|
||||
{ printf ("\n\nLine %d : fopen returned NULL.\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
fwrite (data, sizeof (data), 1, file) ;
|
||||
fclose (file) ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
sndfile = sf_open (filename, SFM_READ, &sfinfo) ;
|
||||
|
||||
if (sndfile)
|
||||
{ printf ("\n\nLine %d : should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
unlink (filename) ;
|
||||
puts ("ok") ;
|
||||
} /* bad_wav_test */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
error_number_test () ;
|
||||
error_value_test () ;
|
||||
|
||||
no_file_test ("no_file.wav") ;
|
||||
zero_length_test ("zero_length.wav") ;
|
||||
bad_wav_test ("bad_wav.wav") ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
** Copyright (C) 2003,2004 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
FILE *bad_file ;
|
||||
const char *bad_wav = "bad_wav.wav" ;
|
||||
const char bad_data [] = "RIFF WAVEfmt " ;
|
||||
|
||||
print_test_name ("open_fail_test", bad_wav) ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
sndfile = sf_open ("let's hope this file doesn't exist", SFM_READ, &sfinfo) ;
|
||||
|
||||
if (sndfile)
|
||||
{ printf ("Line %d: should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if ((bad_file = fopen (bad_wav, "w")) == NULL)
|
||||
{ printf ("Line %d: fopen returned NULL.\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
fwrite (bad_data, sizeof (bad_data), 1, bad_file) ;
|
||||
fclose (bad_file) ;
|
||||
|
||||
sndfile = sf_open (bad_wav, SFM_READ, &sfinfo) ;
|
||||
|
||||
if (sndfile)
|
||||
{ printf ("Line %d: should not have received a valid SNDFILE* pointer.\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
unlink (bad_wav) ;
|
||||
puts ("ok") ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 24440323-00b1-4e4b-87c5-0e3b7e9605e9
|
||||
*/
|
Loading…
Reference in New Issue
Block a user