diff --git a/tests/fix_this.c b/tests/fix_this.c index 4cbb8d43..8ec06c6b 100644 --- a/tests/fix_this.c +++ b/tests/fix_this.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2012 Erik de Castro Lopo +** Copyright (C) 1999-2014 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 @@ -172,7 +172,7 @@ lcomp_test_int (const char *str, const char *filename, int filetype, double marg */ if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM) for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (abs (data [k] / scale) > decay_response (k)) + if (ABS (data [k] / scale) > decay_response (k)) { printf ("Line %d : Incorrect sample B (#%d : abs (%d) should be < %d).\n", __LINE__, k, data [k], decay_response (k)) ; exit (1) ; } ; diff --git a/tests/lossy_comp_test.c b/tests/lossy_comp_test.c index 5f9f593f..c0723737 100644 --- a/tests/lossy_comp_test.c +++ b/tests/lossy_comp_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 1999-2012 Erik de Castro Lopo +** Copyright (C) 1999-2014 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 @@ -838,7 +838,7 @@ lcomp_test_int (const char *filename, int filetype, int channels, double margin) */ if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM) for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (abs (data [channels * k] / scale) > decay_response (channels * k)) + if (ABS (data [channels * k] / scale) > decay_response (channels * k)) { printf ("\n\nLine %d : Incorrect sample B (#%d : abs (%d) should be < %d).\n", __LINE__, channels * k, data [channels * k], decay_response (channels * k)) ; exit (1) ; } ; @@ -1032,7 +1032,7 @@ lcomp_test_float (const char *filename, int filetype, int channels, double margi */ if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM) for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (abs (data [channels * k]) > decay_response (channels * k)) + if (ABS (data [channels * k]) > decay_response (channels * k)) { printf ("\n\nLine %d : Incorrect sample B (#%d : abs (%f) should be < %d).\n", __LINE__, channels * k, data [channels * k], decay_response (channels * k)) ; exit (1) ; } ; @@ -1207,7 +1207,7 @@ lcomp_test_double (const char *filename, int filetype, int channels, double marg oct_save_double (orig, data, datalen) ; exit (1) ; } ; - half_max_abs = LCT_MAX (half_max_abs, abs (0.5 * data [k])) ; + half_max_abs = LCT_MAX (half_max_abs, ABS (0.5 * data [k])) ; } ; if (half_max_abs < 1.0) @@ -1226,7 +1226,7 @@ lcomp_test_double (const char *filename, int filetype, int channels, double marg */ if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM) for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (abs (data [channels * k]) > decay_response (channels * k)) + if (ABS (data [channels * k]) > decay_response (channels * k)) { printf ("\n\nLine %d : Incorrect sample B (#%d : abs (%f) should be < %d).\n", __LINE__, channels * k, data [channels * k], decay_response (channels * k)) ; exit (1) ; } ; @@ -1421,7 +1421,7 @@ channels = 1 ; oct_save_short (orig, smooth, datalen) ; exit (1) ; } ; - half_max_abs = LCT_MAX (half_max_abs, abs (0.5 * data [k])) ; + half_max_abs = LCT_MAX (half_max_abs, ABS (0.5 * data [k])) ; } ; if (half_max_abs < 1) @@ -1437,7 +1437,7 @@ channels = 1 ; if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM && (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610) for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (abs (data [k]) > decay_response (k)) + if (ABS (data [k]) > decay_response (k)) { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, data [k], decay_response (k)) ; exit (1) ; } ; @@ -1824,7 +1824,7 @@ printf ("** fix this ** ") ; oct_save_float (orig, smooth, datalen) ; exit (1) ; } ; - half_max_abs = LCT_MAX (half_max_abs, abs (0.5 * data [k])) ; + half_max_abs = LCT_MAX (half_max_abs, ABS (0.5 * data [k])) ; } ; if (half_max_abs <= 0.0) @@ -1841,7 +1841,7 @@ printf ("** fix this ** ") ; if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM && (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610) for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (abs (data [k]) > decay_response (k)) + if (ABS (data [k]) > decay_response (k)) { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, (int) data [k], (int) decay_response (k)) ; exit (1) ; } ; @@ -2033,7 +2033,7 @@ channels = 1 ; if ((sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_MS_ADPCM && (sfinfo.format & SF_FORMAT_SUBMASK) != SF_FORMAT_GSM610) for (k = 0 ; k < sfinfo.frames - datalen ; k++) - if (abs (data [k]) > decay_response (k)) + if (ABS (data [k]) > decay_response (k)) { printf ("\n\nLine %d: Incorrect sample (#%" PRId64 " : abs (%d) should be < %d).\n", __LINE__, datalen + k, (int) data [k], (int) decay_response (k)) ; exit (1) ; } ; diff --git a/tests/raw_test.c b/tests/raw_test.c index 002f3ee4..6728e368 100644 --- a/tests/raw_test.c +++ b/tests/raw_test.c @@ -1,5 +1,5 @@ /* -** Copyright (C) 2002-2012 Erik de Castro Lopo +** Copyright (C) 2002-2014 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 @@ -84,7 +84,7 @@ raw_offset_test (const char *filename, int typeminor) sndfile = test_open_file_or_die (filename, SFM_READ, &sfinfo, SF_TRUE, __LINE__) ; check_log_buffer_or_die (sndfile, __LINE__) ; - if (abs (BUFFER_LEN - sfinfo.frames) > 1) + if (ABS (BUFFER_LEN - sfinfo.frames) > 1) { printf ("\n\nLine %d : Incorrect sample count (%" PRId64 " should be %d)\n", __LINE__, sfinfo.frames, BUFFER_LEN) ; dump_log_buffer (sndfile) ; exit (1) ; diff --git a/tests/utils.tpl b/tests/utils.tpl index 1f24947c..dc55fa44 100644 --- a/tests/utils.tpl +++ b/tests/utils.tpl @@ -1,6 +1,6 @@ [+ AutoGen5 template h c +] /* -** Copyright (C) 2002-2013 Erik de Castro Lopo +** Copyright (C) 2002-2014 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 @@ -37,6 +37,7 @@ extern "C" { #define ARRAY_LEN(x) ((int) (sizeof (x)) / (sizeof ((x) [0]))) #define SIGNED_SIZEOF(x) ((int64_t) (sizeof (x))) #define NOT(x) (! (x)) +#define ABS(x) ((x) >= 0 ? (x) : -(x)) #define PIPE_INDEX(x) ((x) + 500) #define PIPE_TEST_LEN 12345 @@ -60,7 +61,7 @@ void write_mono_file (const char * filename, int format, int srate, float * outp #ifdef __GNUC__ static inline void exit_if_true (int test, const char *format, ...) -#ifdef __USE_MINGW_ANSI_STDIO +#if (defined (__USE_MINGW_ANSI_STDIO) && __USE_MINGW_ANSI_STDIO) __attribute__ ((format (gnu_printf, 2, 3))) ; #else __attribute__ ((format (printf, 2, 3))) ;