irplib_utils-test.c

00001 /*                                                                              *
00002  *   This file is part of the ESO IRPLIB package                                *
00003  *   Copyright (C) 2004,2005 European Southern Observatory                      *
00004  *                                                                              *
00005  *   This library is free software; you can redistribute it and/or modify       *
00006  *   it under the terms of the GNU General Public License as published by       *
00007  *   the Free Software Foundation; either version 2 of the License, or          *
00008  *   (at your option) any later version.                                        *
00009  *                                                                              *
00010  *   This program is distributed in the hope that it will be useful,            *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
00013  *   GNU General Public License for more details.                               *
00014  *                                                                              *
00015  *   You should have received a copy of the GNU General Public License          *
00016  *   along with this program; if not, write to the Free Software                *
00017  *   Foundation, 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA       *
00018  *                                                                              */
00019  
00020 #ifdef HAVE_CONFIG_H
00021 #  include <config.h>
00022 #endif
00023 
00024 /*-----------------------------------------------------------------------------
00025                                 Includes
00026  -----------------------------------------------------------------------------*/
00027 
00028 #include <irplib_utils.h>
00029 #include <irplib_test.h>
00030 #include <string.h>
00031 #include <float.h>
00032 
00033 /*-----------------------------------------------------------------------------
00034                                 Defines
00035  -----------------------------------------------------------------------------*/
00036 
00037 /*----------------------------------------------------------------------------*/
00041 /*----------------------------------------------------------------------------*/
00042 
00043 /*----------------------------------------------------------------------------*/
00047 /*----------------------------------------------------------------------------*/
00048 static void
00049 test_irplib_isnaninf(void)
00050 {
00051     double infinity = DBL_MAX * DBL_MAX;
00052     double number[] = {17, 0};
00053 
00054     /* The computation  oo/oo  must result in NaN according to
00055        the IEEE 754 standard. However, some GCC 4.x versions erroneously 
00056        optimize this to 1. 
00057 
00058        Alternatively, a NaN could be produced using a IEEE 754 defined bit
00059        pattern. But that is likely to depend on the machine's word size.
00060        Therefore this test is disabled.
00061 
00062        double not_a_number = infinity / infinity;
00063     */
00064 
00065     irplib_test( !irplib_isnan(infinity) );
00066     /* irplib_test(  irplib_isnan(not_a_number) ); */
00067     irplib_test( !irplib_isnan(number[0]) );
00068     irplib_test( !irplib_isnan(number[1]) );
00069 
00070     irplib_test(  irplib_isinf(infinity) );
00071     /* irplib_test( !irplib_isinf(not_a_number) ); */
00072     irplib_test( !irplib_isinf(number[0]) );
00073     irplib_test( !irplib_isinf(number[1]) );
00074 
00075     return;
00076 }
00077 
00078 /*----------------------------------------------------------------------------*/
00082 /*----------------------------------------------------------------------------*/
00083 
00084 int main(void)
00085 {
00086     /* Initialize CPL + IRPLIB */
00087     IRPLIB_TEST_INIT;
00088 
00089     test_irplib_isnaninf();
00090 
00091     IRPLIB_TEST_END;
00092 }

Generated on Thu Nov 15 14:32:26 2007 for UVES Pipeline Reference Manual by  doxygen 1.5.1