758612eaf8f85c374115b46ba98de29ef48e42f9
2 ** Copyright (C) 2003-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation; either version 2 of the License, or
7 ** (at your option) any later version.
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ** GNU General Public License for more details.
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program; if not, write to the Free Software
16 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #define BUFFER_LEN (1 << 10)
35 #define LOG_BUFFER_SIZE 1024
37 static void string_start_test (const char *filename
, int typemajor
) ;
38 static void string_start_end_test (const char *filename
, int typemajor
) ;
39 static void string_multi_set_test (const char *filename
, int typemajor
) ;
40 static void string_rdwr_test (const char *filename
, int typemajor
) ;
41 static void string_short_rdwr_test (const char *filename
, int typemajor
) ;
43 static void software_string_test (const char *filename
) ;
45 static int str_count (const char * haystack
, const char * needle
) ;
48 main (int argc
, char *argv
[])
53 { printf ("Usage : %s <test>\n", argv
[0]) ;
54 printf (" Where <test> is one of the following:\n") ;
55 printf (" wav - test adding strings to WAV files\n") ;
56 printf (" aiff - test adding strings to AIFF files\n") ;
57 printf (" flac - test adding strings to FLAC files\n") ;
58 printf (" ogg - test adding strings to OGG files\n") ;
59 printf (" all - perform all tests\n") ;
63 do_all
=! strcmp (argv
[1], "all") ;
65 if (do_all
|| ! strcmp (argv
[1], "wav"))
66 { string_start_end_test ("strings.wav", SF_FORMAT_WAV
) ;
67 string_multi_set_test ("multi.wav", SF_FORMAT_WAV
) ;
68 string_rdwr_test ("rdwr.wav", SF_FORMAT_WAV
) ;
69 string_short_rdwr_test ("short_rdwr.wav", SF_FORMAT_WAV
) ;
71 string_start_end_test ("strings.wavex", SF_FORMAT_WAVEX
) ;
72 string_multi_set_test ("multi.wavex", SF_FORMAT_WAVEX
) ;
73 string_rdwr_test ("rdwr.wavex", SF_FORMAT_WAVEX
) ;
74 string_short_rdwr_test ("short_rdwr.wavex", SF_FORMAT_WAVEX
) ;
76 string_start_end_test ("strings.rifx", SF_ENDIAN_BIG
| SF_FORMAT_WAV
) ;
77 string_multi_set_test ("multi.rifx", SF_ENDIAN_BIG
| SF_FORMAT_WAV
) ;
78 string_rdwr_test ("rdwr.rifx", SF_ENDIAN_BIG
| SF_FORMAT_WAV
) ;
79 string_short_rdwr_test ("short_rdwr.rifx", SF_ENDIAN_BIG
| SF_FORMAT_WAV
) ;
81 software_string_test ("software_string.wav") ;
85 if (do_all
|| ! strcmp (argv
[1], "aiff"))
86 { string_start_end_test ("strings.aiff", SF_FORMAT_AIFF
) ;
88 string_multi_set_test ("multi.aiff", SF_FORMAT_AIFF) ;
89 string_rdwr_test ("rdwr.aiff", SF_FORMAT_AIFF) ;
90 string_short_rdwr_test ("short_rdwr.aiff", SF_FORMAT_AIFF) ;
95 if (do_all
|| ! strcmp (argv
[1], "flac"))
96 { if (HAVE_EXTERNAL_LIBS
)
97 string_start_test ("strings.flac", SF_FORMAT_FLAC
) ;
99 puts (" No FLAC tests because FLAC support was not compiled in.") ;
103 if (do_all
|| ! strcmp (argv
[1], "ogg"))
104 { if (HAVE_EXTERNAL_LIBS
)
105 string_start_test ("vorbis.oga", SF_FORMAT_OGG
) ;
107 puts (" No Ogg/Vorbis tests because Ogg/Vorbis support was not compiled in.") ;
111 if (do_all
|| ! strcmp (argv
[1], "rf64"))
112 { puts ("\n\n **** String test not working yet for RF64 format. ****\n") ;
114 string_start_end_test ("strings.rf64", SF_FORMAT_RF64) ;
115 string_multi_set_test ("multi.rf64", SF_FORMAT_RF64) ;
116 string_rdwr_test ("rdwr.rf64", SF_FORMAT_RF64) ;
117 string_short_rdwr_test ("short_rdwr.rf64", SF_FORMAT_RF64) ;
123 { printf ("Mono : ************************************\n") ;
124 printf ("Mono : * No '%s' test defined.\n", argv
[1]) ;
125 printf ("Mono : ************************************\n") ;
133 /*============================================================================================
134 ** Here are the test functions.
138 software
[] = "software (libsndfile-X.Y.Z)",
139 artist
[] = "The Artist",
140 copyright
[] = "Copyright (c) 2001 Artist",
141 comment
[] = "Comment goes here!!!",
142 date
[] = "2001/01/27",
143 album
[] = "The Album",
144 license
[] = "The license",
145 title
[] = "This is the title",
146 long_title
[] = "This is a very long and very boring title for this file",
147 long_artist
[] = "The artist who kept on changing its name",
148 genre
[] = "The genre",
149 trackno
[] = "Track three" ;
152 static short data_out
[BUFFER_LEN
] ;
155 string_start_end_test (const char *filename
, int typemajor
)
161 typemajor
= typemajor
;
163 print_test_name ("string_start_end_test", filename
) ;
165 sfinfo
.samplerate
= 44100 ;
166 sfinfo
.channels
= 1 ;
168 sfinfo
.format
= typemajor
| SF_FORMAT_PCM_16
;
170 file
= test_open_file_or_die (filename
, SFM_WRITE
, &sfinfo
, SF_TRUE
, __LINE__
) ;
172 /* Write stuff at start of file. */
173 sf_set_string (file
, SF_STR_TITLE
, filename
) ;
174 sf_set_string (file
, SF_STR_SOFTWARE
, software
) ;
175 sf_set_string (file
, SF_STR_ARTIST
, artist
) ;
176 sf_set_string (file
, SF_STR_GENRE
, genre
) ;
177 sf_set_string (file
, SF_STR_TRACKNUMBER
, trackno
) ;
179 /* Write data to file. */
180 test_write_short_or_die (file
, 0, data_out
, BUFFER_LEN
, __LINE__
) ;
181 test_seek_or_die (file
, 0, SEEK_SET
, 0, sfinfo
.channels
, __LINE__
) ;
183 /* Write more stuff at end of file. */
184 sf_set_string (file
, SF_STR_COPYRIGHT
, copyright
) ;
185 sf_set_string (file
, SF_STR_COMMENT
, comment
) ;
186 sf_set_string (file
, SF_STR_DATE
, date
) ;
187 sf_set_string (file
, SF_STR_ALBUM
, album
) ;
188 sf_set_string (file
, SF_STR_LICENSE
, license
) ;
192 file
= test_open_file_or_die (filename
, SFM_READ
, &sfinfo
, SF_TRUE
, __LINE__
) ;
194 check_log_buffer_or_die (file
, __LINE__
) ;
196 if (sfinfo
.frames
!= BUFFER_LEN
)
197 { printf ("***** Bad frame count %d (should be %d)\n\n", (int) sfinfo
.frames
, BUFFER_LEN
) ;
201 cptr
= sf_get_string (file
, SF_STR_TITLE
) ;
202 if (cptr
== NULL
|| strcmp (filename
, cptr
) != 0)
205 printf (" Bad filename : %s\n", cptr
) ;
208 cptr
= sf_get_string (file
, SF_STR_COPYRIGHT
) ;
209 if (cptr
== NULL
|| strcmp (copyright
, cptr
) != 0)
212 printf (" Bad copyright : %s\n", cptr
) ;
215 cptr
= sf_get_string (file
, SF_STR_SOFTWARE
) ;
216 if (cptr
== NULL
|| strstr (cptr
, software
) != cptr
)
219 printf (" Bad software : %s\n", cptr
) ;
222 if (str_count (cptr
, "libsndfile") != 1)
225 printf (" Bad software : %s\n", cptr
) ;
228 cptr
= sf_get_string (file
, SF_STR_ARTIST
) ;
229 if (cptr
== NULL
|| strcmp (artist
, cptr
) != 0)
232 printf (" Bad artist : %s\n", cptr
) ;
235 cptr
= sf_get_string (file
, SF_STR_COMMENT
) ;
236 if (cptr
== NULL
|| strcmp (comment
, cptr
) != 0)
239 printf (" Bad comment : %s\n", cptr
) ;
242 if (typemajor
!= SF_FORMAT_AIFF
)
243 { cptr
= sf_get_string (file
, SF_STR_DATE
) ;
244 if (cptr
== NULL
|| strcmp (date
, cptr
) != 0)
247 printf (" Bad date : %s\n", cptr
) ;
250 cptr
= sf_get_string (file
, SF_STR_GENRE
) ;
251 if (cptr
== NULL
|| strcmp (genre
, cptr
) != 0)
254 printf (" Bad genre : %s\n", cptr
) ;
259 { case SF_FORMAT_AIFF
:
261 case SF_FORMAT_WAVEX
:
262 case SF_ENDIAN_BIG
| SF_FORMAT_WAV
:
266 cptr
= sf_get_string (file
, SF_STR_ALBUM
) ;
267 if (cptr
== NULL
|| strcmp (album
, cptr
) != 0)
270 printf (" Bad album : %s\n", cptr
) ;
273 cptr
= sf_get_string (file
, SF_STR_LICENSE
) ;
274 if (cptr
== NULL
|| strcmp (license
, cptr
) != 0)
277 printf (" Bad license : %s\n", cptr
) ;
280 cptr
= sf_get_string (file
, SF_STR_TRACKNUMBER
) ;
281 if (cptr
== NULL
|| strcmp (genre
, cptr
) != 0)
284 printf (" Bad track no. : %s\n", cptr
) ;
290 { printf ("\n*** Error count : %d ***\n\n", errors
) ;
291 dump_log_buffer (file
) ;
299 } /* string_start_end_test */
302 string_start_test (const char *filename
, int typemajor
)
308 print_test_name ("string_start_test", filename
) ;
310 sfinfo
.samplerate
= 44100 ;
311 sfinfo
.channels
= 1 ;
315 { case SF_FORMAT_OGG
:
316 sfinfo
.format
= typemajor
| SF_FORMAT_VORBIS
;
320 sfinfo
.format
= typemajor
| SF_FORMAT_PCM_16
;
324 file
= test_open_file_or_die (filename
, SFM_WRITE
, &sfinfo
, SF_TRUE
, __LINE__
) ;
326 /* Write stuff at start of file. */
327 sf_set_string (file
, SF_STR_TITLE
, filename
) ;
328 sf_set_string (file
, SF_STR_SOFTWARE
, software
) ;
329 sf_set_string (file
, SF_STR_ARTIST
, artist
) ;
330 sf_set_string (file
, SF_STR_COPYRIGHT
, copyright
) ;
331 sf_set_string (file
, SF_STR_COMMENT
, comment
) ;
332 sf_set_string (file
, SF_STR_DATE
, date
) ;
333 sf_set_string (file
, SF_STR_ALBUM
, album
) ;
334 sf_set_string (file
, SF_STR_LICENSE
, license
) ;
336 /* Write data to file. */
337 test_write_short_or_die (file
, 0, data_out
, BUFFER_LEN
, __LINE__
) ;
341 file
= test_open_file_or_die (filename
, SFM_READ
, &sfinfo
, SF_TRUE
, __LINE__
) ;
343 check_log_buffer_or_die (file
, __LINE__
) ;
345 if (sfinfo
.frames
!= BUFFER_LEN
)
346 { printf ("***** Bad frame count %d (should be %d)\n\n", (int) sfinfo
.frames
, BUFFER_LEN
) ;
350 cptr
= sf_get_string (file
, SF_STR_TITLE
) ;
351 if (cptr
== NULL
|| strcmp (filename
, cptr
) != 0)
354 printf (" Bad filename : %s\n", cptr
) ;
357 cptr
= sf_get_string (file
, SF_STR_COPYRIGHT
) ;
358 if (cptr
== NULL
|| strcmp (copyright
, cptr
) != 0)
361 printf (" Bad copyright : %s\n", cptr
) ;
364 cptr
= sf_get_string (file
, SF_STR_SOFTWARE
) ;
365 if (cptr
== NULL
|| strstr (cptr
, software
) != cptr
)
368 printf (" Bad software : %s\n", cptr
) ;
371 if (str_count (cptr
, "libsndfile") != 1)
374 printf (" Bad software : %s\n", cptr
) ;
377 cptr
= sf_get_string (file
, SF_STR_ARTIST
) ;
378 if (cptr
== NULL
|| strcmp (artist
, cptr
) != 0)
381 printf (" Bad artist : %s\n", cptr
) ;
384 cptr
= sf_get_string (file
, SF_STR_COMMENT
) ;
385 if (cptr
== NULL
|| strcmp (comment
, cptr
) != 0)
388 printf (" Bad comment : %s\n", cptr
) ;
391 if (typemajor
!= SF_FORMAT_AIFF
)
392 { cptr
= sf_get_string (file
, SF_STR_DATE
) ;
393 if (cptr
== NULL
|| strcmp (date
, cptr
) != 0)
396 printf (" Bad date : %s\n", cptr
) ;
400 if (typemajor
!= SF_FORMAT_WAV
&& typemajor
!= SF_FORMAT_AIFF
)
401 { cptr
= sf_get_string (file
, SF_STR_ALBUM
) ;
402 if (cptr
== NULL
|| strcmp (album
, cptr
) != 0)
405 printf (" Bad album : %s\n", cptr
) ;
409 if (typemajor
!= SF_FORMAT_WAV
&& typemajor
!= SF_FORMAT_AIFF
)
410 { cptr
= sf_get_string (file
, SF_STR_LICENSE
) ;
411 if (cptr
== NULL
|| strcmp (license
, cptr
) != 0)
414 printf (" Bad license : %s\n", cptr
) ;
419 { printf ("\n*** Error count : %d ***\n\n", errors
) ;
420 dump_log_buffer (file
) ;
428 } /* string_start_test */
431 string_multi_set_test (const char *filename
, int typemajor
)
433 new_software
[] = "new software (libsndfile-X.Y.Z)",
434 new_copyright
[] = "Copyright (c) 2001 New Artist",
435 new_artist
[] = "The New Artist",
436 new_title
[] = "This is the new title" ;
438 static char buffer
[2048] ;
443 print_test_name (__func__
, filename
) ;
445 sfinfo
.format
= typemajor
| SF_FORMAT_PCM_16
;
446 sfinfo
.samplerate
= 44100 ;
447 sfinfo
.channels
= 1 ;
450 file
= test_open_file_or_die (filename
, SFM_WRITE
, &sfinfo
, SF_TRUE
, __LINE__
) ;
452 /* Write stuff at start of file. */
453 sf_set_string (file
, SF_STR_TITLE
, title
) ;
454 sf_set_string (file
, SF_STR_SOFTWARE
, software
) ;
455 sf_set_string (file
, SF_STR_ARTIST
, artist
) ;
457 /* Write data to file. */
458 test_write_short_or_die (file
, 0, data_out
, BUFFER_LEN
, __LINE__
) ;
460 /* Write it all again. */
462 sf_set_string (file
, SF_STR_TITLE
, new_title
) ;
463 sf_set_string (file
, SF_STR_SOFTWARE
, new_software
) ;
464 sf_set_string (file
, SF_STR_ARTIST
, new_artist
) ;
466 sf_set_string (file
, SF_STR_COPYRIGHT
, copyright
) ;
467 sf_set_string (file
, SF_STR_COMMENT
, comment
) ;
468 sf_set_string (file
, SF_STR_DATE
, date
) ;
469 sf_set_string (file
, SF_STR_ALBUM
, album
) ;
470 sf_set_string (file
, SF_STR_LICENSE
, license
) ;
471 sf_set_string (file
, SF_STR_COPYRIGHT
, new_copyright
) ;
472 sf_set_string (file
, SF_STR_COMMENT
, comment
) ;
473 sf_set_string (file
, SF_STR_DATE
, date
) ;
474 sf_set_string (file
, SF_STR_ALBUM
, album
) ;
475 sf_set_string (file
, SF_STR_LICENSE
, license
) ;
479 file
= test_open_file_or_die (filename
, SFM_READ
, &sfinfo
, SF_TRUE
, __LINE__
) ;
480 sf_command (file
, SFC_GET_LOG_INFO
, buffer
, sizeof (buffer
)) ;
483 count
= str_count (buffer
, new_title
) ;
484 exit_if_true (count
< 1, "\n\nLine %d : Could not find new_title in :\n%s\n", __LINE__
, buffer
) ;
485 exit_if_true (count
> 1, "\n\nLine %d : new_title appears %d times in :\n\n%s\n", __LINE__
, count
, buffer
) ;
487 count
= str_count (buffer
, software
) ;
488 exit_if_true (count
< 1, "\n\nLine %d : Could not find new_software in :\n%s\n", __LINE__
, buffer
) ;
489 exit_if_true (count
> 1, "\n\nLine %d : new_software appears %d times in :\n\n%s\n", __LINE__
, count
, buffer
) ;
491 count
= str_count (buffer
, new_artist
) ;
492 exit_if_true (count
< 1, "\n\nLine %d : Could not find new_artist in :\n%s\n", __LINE__
, buffer
) ;
493 exit_if_true (count
> 1, "\n\nLine %d : new_artist appears %d times in :\n\n%s\n", __LINE__
, count
, buffer
) ;
495 count
= str_count (buffer
, new_copyright
) ;
496 exit_if_true (count
< 1, "\n\nLine %d : Could not find new_copyright in :\n%s\n", __LINE__
, buffer
) ;
497 exit_if_true (count
> 1, "\n\nLine %d : new_copyright appears %d times in :\n\n%s\n", __LINE__
, count
, buffer
) ;
502 } /* string_multi_set_test */
505 string_rdwr_test (const char *filename
, int typemajor
)
511 print_test_name (__func__
, filename
) ;
512 create_short_sndfile (filename
, typemajor
| SF_FORMAT_PCM_16
, 2) ;
514 memset (&sfinfo
, 0, sizeof (sfinfo
)) ;
515 file
= test_open_file_or_die (filename
, SFM_RDWR
, &sfinfo
, SF_FALSE
, __LINE__
) ;
516 frames
= sfinfo
.frames
;
517 sf_set_string (file
, SF_STR_TITLE
, title
) ;
520 file
= test_open_file_or_die (filename
, SFM_READ
, &sfinfo
, SF_FALSE
, __LINE__
) ;
521 exit_if_true (frames
!= sfinfo
.frames
, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__
, sfinfo
.frames
, frames
) ;
522 str
= sf_get_string (file
, SF_STR_TITLE
) ;
523 exit_if_true (str
== NULL
, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__
) ;
524 exit_if_true (strcmp (str
, title
) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__
) ;
527 file
= test_open_file_or_die (filename
, SFM_RDWR
, &sfinfo
, SF_FALSE
, __LINE__
) ;
528 frames
= sfinfo
.frames
;
529 sf_set_string (file
, SF_STR_TITLE
, title
) ;
532 file
= test_open_file_or_die (filename
, SFM_RDWR
, &sfinfo
, SF_FALSE
, __LINE__
) ;
533 str
= sf_get_string (file
, SF_STR_TITLE
) ;
534 exit_if_true (str
== NULL
, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__
) ;
535 sf_set_string (file
, SF_STR_ARTIST
, artist
) ;
538 file
= test_open_file_or_die (filename
, SFM_READ
, &sfinfo
, SF_FALSE
, __LINE__
) ;
540 str
= sf_get_string (file
, SF_STR_ARTIST
) ;
541 exit_if_true (str
== NULL
, "\n\nLine %d : SF_STR_ARTIST string is NULL.\n", __LINE__
) ;
542 exit_if_true (strcmp (str
, artist
) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__
) ;
544 str
= sf_get_string (file
, SF_STR_TITLE
) ;
545 exit_if_true (str
== NULL
, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__
) ;
546 exit_if_true (strcmp (str
, title
) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__
) ;
548 exit_if_true (frames
!= sfinfo
.frames
, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__
, sfinfo
.frames
, frames
) ;
554 } /* string_rdwr_test */
557 string_short_rdwr_test (const char *filename
, int typemajor
)
560 sf_count_t frames
= BUFFER_LEN
;
563 print_test_name (__func__
, filename
) ;
565 memset (&sfinfo
, 0, sizeof (sfinfo
)) ;
566 sfinfo
.format
= typemajor
| SF_FORMAT_PCM_16
;
567 sfinfo
.samplerate
= 44100 ;
568 sfinfo
.channels
= 1 ;
571 file
= test_open_file_or_die (filename
, SFM_WRITE
, &sfinfo
, SF_FALSE
, __LINE__
) ;
573 /* Write data to file. */
574 test_write_short_or_die (file
, 0, data_out
, BUFFER_LEN
, __LINE__
) ;
576 sf_set_string (file
, SF_STR_TITLE
, long_title
) ;
577 sf_set_string (file
, SF_STR_ARTIST
, long_artist
) ;
580 /* Open the file RDWR. */
581 file
= test_open_file_or_die (filename
, SFM_RDWR
, &sfinfo
, SF_FALSE
, __LINE__
) ;
582 exit_if_true (frames
!= sfinfo
.frames
, "\n\nLine %d : Frame count %lld should be %lld.\n", __LINE__
, sfinfo
.frames
, frames
) ;
583 str
= sf_get_string (file
, SF_STR_TITLE
) ;
584 exit_if_true (str
== NULL
, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__
) ;
585 exit_if_true (strcmp (str
, long_title
) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__
) ;
586 str
= sf_get_string (file
, SF_STR_ARTIST
) ;
587 exit_if_true (str
== NULL
, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__
) ;
588 exit_if_true (strcmp (str
, long_artist
) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__
) ;
590 /* Change title and artist. */
591 sf_set_string (file
, SF_STR_TITLE
, title
) ;
592 sf_set_string (file
, SF_STR_ARTIST
, artist
) ;
596 file
= test_open_file_or_die (filename
, SFM_READ
, &sfinfo
, SF_FALSE
, __LINE__
) ;
598 check_log_buffer_or_die (file
, __LINE__
) ;
600 str
= sf_get_string (file
, SF_STR_TITLE
) ;
601 exit_if_true (str
== NULL
, "\n\nLine %d : SF_STR_TITLE string is NULL.\n", __LINE__
) ;
602 exit_if_true (strcmp (str
, title
) != 0, "\n\nLine %d : SF_STR_TITLE doesn't match what was written.\n", __LINE__
) ;
604 str
= sf_get_string (file
, SF_STR_ARTIST
) ;
605 exit_if_true (str
== NULL
, "\n\nLine %d : SF_STR_ARTIST string is NULL.\n", __LINE__
) ;
606 exit_if_true (strcmp (str
, artist
) != 0, "\n\nLine %d : SF_STR_ARTIST doesn't match what was written.\n", __LINE__
) ;
612 } /* string_short_rdwr_test */
615 str_count (const char * haystack
, const char * needle
)
618 while ((haystack
= strstr (haystack
, needle
)) != NULL
)
626 #define MIN(a,b) ((a) < (b) ? (a) : (b))
630 software_string_test (const char *filename
)
633 print_test_name (__func__
, filename
) ;
635 for (k
= 0 ; k
< 50 ; k
++)
636 { const char *result
;
641 sf_info_setup (&info
, SF_FORMAT_WAV
| SF_FORMAT_PCM_16
, 44100, 1) ;
642 file
= test_open_file_or_die (filename
, SFM_WRITE
, &info
, SF_TRUE
, __LINE__
) ;
644 snprintf (sfname
, MIN (k
, sizeof (sfname
)), "%s", "abcdefghijklmnopqrestvwxyz0123456789abcdefghijklmnopqrestvwxyz") ;
646 exit_if_true (sf_set_string (file
, SF_STR_SOFTWARE
, sfname
),
647 "\n\nLine %d : sf_set_string (f, SF_STR_SOFTWARE, '%s') failed : %s\n", __LINE__
, sfname
, sf_strerror (file
)) ;
651 file
= test_open_file_or_die (filename
, SFM_READ
, &info
, SF_TRUE
, __LINE__
) ;
652 result
= sf_get_string (file
, SF_STR_SOFTWARE
) ;
654 exit_if_true (result
== NULL
, "\n\nLine %d : sf_get_string (file, SF_STR_SOFTWARE) returned NULL.\n\n", __LINE__
) ;
656 exit_if_true (strstr (result
, sfname
) != result
,
657 "\n\nLine %d : String '%s''%s' -> '%s'\n\n", sfname
, result
) ;
663 } /* new_test_test */