From 19f5d657941bdec991e7e5abd2748708b6775bc0 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Fri, 14 Dec 2007 20:41:33 +1100 Subject: [PATCH] tests/utils.(def|tpl) : Add compare_XXX_or_die functions. --- ChangeLog | 3 +++ tests/utils.def | 8 ++++---- tests/utils.tpl | 28 +++++++++++++++++++++++++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3c792ae..143266ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ Add a test (currently failing) for stereo seeking on Ogg Vorbis files. Test case supplied by Bodo. + * tests/utils.(def|tpl) + Add compare_XXX_or_die functions. + 2007-12-05 Erik de Castro Lopo * src/aiff.c diff --git a/tests/utils.def b/tests/utils.def index a0063cc4..0d94183d 100644 --- a/tests/utils.def +++ b/tests/utils.def @@ -12,22 +12,22 @@ float_type = { io_type = { io_element = short ; - format_str = "\"% d\\n\"" ; + format_str = "\"% d\"" ; }; io_type = { io_element = int ; - format_str = "\"% d\\n\"" ; + format_str = "\"% d\"" ; }; io_type = { io_element = float ; - format_str = "\"% g\\n\"" ; + format_str = "\"% g\"" ; }; io_type = { io_element = double ; - format_str = "\"% g\\n\"" ; + format_str = "\"% g\"" ; }; read_op = { diff --git a/tests/utils.tpl b/tests/utils.tpl index ee7966b2..b0dab898 100644 --- a/tests/utils.tpl +++ b/tests/utils.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template h c +] /* -** Copyright (C) 2002-2005 Erik de Castro Lopo +** Copyright (C) 2002-2007 Erik de Castro Lopo ** ** 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 @@ -114,6 +114,11 @@ void test_seek_or_die (SNDFILE *file, int pass, const [+ (get "io_element") +] *test, sf_count_t [+ (get "count_name") +], int line_num) ; [+ ENDFOR io_type +][+ ENDFOR write_op +] +[+ FOR io_type ++]void compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *left, const [+ (get "io_element") +] *right, unsigned count, int line_num) ; +[+ ENDFOR io_type +] + + void gen_lowpass_noise_float (float *data, int len) ; int file_length (const char * fname) ; @@ -290,7 +295,7 @@ oct_save_[+ (get "io_element") +] (const [+ (get "io_element") +] *a, const [+ ( fprintf (file, "# columns: 1\n") ; for (k = 0 ; k < len ; k++) - fprintf (file, [+ (get "format_str") +], a [k]) ; + fprintf (file, [+ (get "format_str") +] "\n", a [k]) ; fprintf (file, "# name: b\n") ; fprintf (file, "# type: matrix\n") ; @@ -298,7 +303,7 @@ oct_save_[+ (get "io_element") +] (const [+ (get "io_element") +] *a, const [+ ( fprintf (file, "# columns: 1\n") ; for (k = 0 ; k < len ; k++) - fprintf (file, [+ (get "format_str") +], b [k]) ; + fprintf (file, [+ (get "format_str") +] "\n", b [k]) ; fclose (file) ; return 0 ; @@ -622,6 +627,23 @@ test_[+ (get "op_element") +]_[+ (get "io_element") +]_or_die (SNDFILE *file, in } /* test_[+ (get "op_element") +]_[+ (get "io_element") +] */ [+ ENDFOR io_type +][+ ENDFOR write_op +] +[+ FOR io_type ++]void +compare_[+ (get "io_element") +]_or_die (const [+ (get "io_element") +] *left, const [+ (get "io_element") +] *right, unsigned count, int line_num) +{ + unsigned k ; + + for (k = 0 ; k < count ;k++) + if (left [k] != right [k]) + { printf ("\n\nLine %d : Error at index %d, " [+ (get "format_str") +] " should be " [+ (get "format_str") +] ".\n\n", line_num, k, left [k], right [k]) ; + exit (1) ; + } ; + + return ; +} /* compare_[+ (get "io_element") +]_or_die */ +[+ ENDFOR io_type +] + + void delete_file (int format, const char *filename) { char rsrc_name [512], *fname ;