mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 17:38:59 +00:00
libsndfile: update to 1.0.19 (LBSNDF-7)
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2009-0186 http://www.mega-nerd.com/libsndfile/libsndfile-1.0.19.tar.gz This will likely require a fresh boostrap to updated source checkouts. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13415 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
104
libs/libsndfile/src/test_float.c
Normal file
104
libs/libsndfile/src/test_float.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
** Copyright (C) 2006-2009 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 Lesser General Public License as published by
|
||||
** the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser 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>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "test_main.h"
|
||||
|
||||
void
|
||||
test_float_convert (void)
|
||||
{ static float data [] =
|
||||
{ 0.0, 1.0, -1.0, 1.0 * M_PI, -1.0 * M_PI,
|
||||
1e9, -1e9, 1e-9, -1e-9, 1e-10, -1e-10,
|
||||
1e-19, -1e-19, 1e19, -1e19, 1e-20, -1e-20,
|
||||
} ;
|
||||
|
||||
int k ;
|
||||
|
||||
print_test_name (__func__) ;
|
||||
|
||||
for (k = 0 ; k < ARRAY_LEN (data) ; k++)
|
||||
{ unsigned char bytes [4] ;
|
||||
float test ;
|
||||
|
||||
float32_le_write (data [k], bytes) ;
|
||||
test = float32_le_read (bytes) ;
|
||||
|
||||
if (fabs (data [k] - test) > 1e-20)
|
||||
{ printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test ) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
float32_be_write (data [k], bytes) ;
|
||||
test = float32_be_read (bytes) ;
|
||||
|
||||
if (fabs (data [k] - test) > 1e-20)
|
||||
{ printf ("\n\nLine %d : Test %d, big endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
} ;
|
||||
|
||||
puts ("ok") ;
|
||||
} /* test_float_convert */
|
||||
|
||||
void
|
||||
test_double_convert (void)
|
||||
{ static double data [] =
|
||||
{ 0.0, 1.0, -1.0, 1.0 * M_PI, -1.0 * M_PI,
|
||||
1e9, -1e9, 1e-9, -1e-9, 1e-10, -1e-10,
|
||||
1e-19, -1e-19, 1e19, -1e19, 1e-20, -1e-20,
|
||||
} ;
|
||||
|
||||
int k ;
|
||||
|
||||
print_test_name (__func__) ;
|
||||
|
||||
for (k = 0 ; k < ARRAY_LEN (data) ; k++)
|
||||
{ unsigned char bytes [8] ;
|
||||
double test ;
|
||||
|
||||
double64_le_write (data [k], bytes) ;
|
||||
test = double64_le_read (bytes) ;
|
||||
|
||||
if (fabs (data [k] - test) > 1e-20)
|
||||
{ printf ("\n\nLine %d : Test %d, little endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test ) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
double64_be_write (data [k], bytes) ;
|
||||
test = double64_be_read (bytes) ;
|
||||
|
||||
if (fabs (data [k] - test) > 1e-20)
|
||||
{ printf ("\n\nLine %d : Test %d, big endian error %.15g -> %.15g.\n\n", __LINE__, k, data [k], test) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
} ;
|
||||
|
||||
puts ("ok") ;
|
||||
} /* test_double_convert */
|
||||
|
Reference in New Issue
Block a user