tests/string_test.c : Add a new string_rdwr_test (currently failing for WAV).

This commit is contained in:
Erik de Castro Lopo 2008-08-17 12:06:35 +10:00
parent f2b953d6ec
commit 82f6b2db86
2 changed files with 69 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2008-08-17 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* tests/string_test.c
Add a new string_rdwr_test (currently failing for WAV).
2008-08-16 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* configure.ac
@ -6,8 +11,16 @@
* examples/sndfile-convert.c
In function copy_metadata(), copy broadcast info if present.
* examples/sndfile-bwf-set.c examples/Makefile.am
Add new file examples/sndfile-bwf-set.c and hook into build.
* examples/copy_data.[ch] examples/Makefile.am
Break some functionality out of sndfile-convert.c so it can be used in
examples/sndfile-bwf-set.c.
* tests/utils.tpl
Add new function create_short_sndfile().
* examples/sndfile-bwf-set.c examples/sndfile-bwf-get.c
examples/Makefile.am
Add new files and hook into build.
2008-08-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2003,2004 Erik de Castro Lopo <erikd@mega-nerd.com>
** Copyright (C) 2003-2008 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
@ -36,6 +36,7 @@
static void string_start_test (const char *filename, int typemajor) ;
static void string_start_end_test (const char *filename, int typemajor) ;
static void string_rdwr_test (const char *filename, int typemajor) ;
static int libsndfile_str_count (const char * cptr) ;
@ -59,6 +60,7 @@ main (int argc, char *argv [])
if (do_all || ! strcmp (argv [1], "wav"))
{ string_start_end_test ("strings.wav", SF_FORMAT_WAV) ;
string_rdwr_test ("rdwr.wav", SF_FORMAT_WAV) ;
test_count++ ;
} ;
@ -105,7 +107,8 @@ static const char
comment [] = "Comment goes here!!!",
date [] = "2001/01/27",
album [] = "The Album",
license [] = "The license" ;
license [] = "The license",
title [] = "This is the title" ;
static short data_out [BUFFER_LEN] ;
@ -367,6 +370,55 @@ string_start_test (const char *filename, int typemajor)
puts ("ok") ;
} /* string_start_test */
static void
string_rdwr_test (const char *filename, int typemajor)
{ SNDFILE *file ;
SF_INFO sfinfo ;
sf_count_t frames ;
const char * str ;
print_test_name (__func__, filename) ;
create_short_sndfile (filename, typemajor | SF_FORMAT_PCM_16, 2) ;
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
frames = sfinfo.frames ;
sf_set_string (file, SF_STR_TITLE, title) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ;
str = sf_get_string (file, SF_STR_TITLE) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
frames = sfinfo.frames ;
sf_set_string (file, SF_STR_TITLE, title) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_RDWR, &sfinfo, SF_FALSE, __LINE__) ;
sf_set_string (file, SF_STR_ARTIST, artist) ;
sf_close (file) ;
file = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_FALSE, __LINE__) ;
exit_if_true (frames != sfinfo.frames, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__, sfinfo.frames, frames) ;
str = sf_get_string (file, SF_STR_ARTIST) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_ARTIST string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, artist) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__) ;
str = sf_get_string (file, SF_STR_TITLE) ;
exit_if_true (str == NULL, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__) ;
exit_if_true (strcmp (str, title) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__) ;
sf_close (file) ;
unlink (filename) ;
puts ("ok") ;
} /* string_rdwr_test */
static int
libsndfile_str_count (const char * str)
{ const char * cptr ;