00001 /* * 00002 * This file is part of the ESO UVES Pipeline * 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 /*----------------------------------------------------------------------------*/ 00024 /*----------------------------------------------------------------------------*/ 00025 00026 #ifdef HAVE_CONFIG_H 00027 # include <config.h> 00028 #endif 00029 00030 /*----------------------------------------------------------------------------- 00031 Includes 00032 -----------------------------------------------------------------------------*/ 00033 00034 #include <irplib_error.h> 00035 #include <irplib_test.h> 00036 00037 #include <cpl.h> 00038 00039 /*----------------------------------------------------------------------------- 00040 Defines 00041 -----------------------------------------------------------------------------*/ 00042 00043 /*----------------------------------------------------------------------------- 00044 Functions prototypes 00045 -----------------------------------------------------------------------------*/ 00046 00049 /*----------------------------------------------------------------------------*/ 00053 /*----------------------------------------------------------------------------*/ 00054 00055 int main(void) 00056 { 00057 /* Initialize CPL + IRPLIB */ 00058 IRPLIB_TEST_INIT; 00059 00060 /* Call irplib_error_push 00061 irplib_error_reset 00062 irplib_error_dump 00063 irplib_error_assure 00064 00065 Not tested here: interaction with CPL error functions 00066 */ 00067 00068 irplib_error_push(CPL_ERROR_DUPLICATING_STREAM, (" ")); 00069 irplib_test_eq( cpl_error_get_code(), CPL_ERROR_DUPLICATING_STREAM ); 00070 00071 irplib_error_push(CPL_ERROR_BAD_FILE_FORMAT, ("A non-empty error message")); 00072 irplib_test_eq( cpl_error_get_code(), CPL_ERROR_BAD_FILE_FORMAT ); 00073 00074 /* Dump stack */ 00075 irplib_error_dump(CPL_MSG_OFF, CPL_MSG_OFF); 00076 00077 irplib_error_reset(); 00078 irplib_test_eq( cpl_error_get_code(), CPL_ERROR_NONE ); 00079 00080 /* Dump nothing */ 00081 irplib_error_dump(CPL_MSG_OFF, CPL_MSG_OFF); 00082 00083 { 00084 int a = 5; 00085 00086 irplib_error_assure( 0 == 0, CPL_ERROR_SINGULAR_MATRIX, 00087 ("Your matrix is singular"), a = 7 ); 00088 00089 irplib_test_eq( cpl_error_get_code(), CPL_ERROR_NONE ); 00090 irplib_test_eq( a, 5 ); 00091 00092 irplib_error_assure( 1 == 0, CPL_ERROR_SINGULAR_MATRIX, 00093 ("Your matrix is singular"), a = 7 ); 00094 00095 irplib_test_eq( cpl_error_get_code(), CPL_ERROR_SINGULAR_MATRIX ); 00096 irplib_test_eq( a, 7 ); 00097 00098 } 00099 00100 irplib_error_reset(); 00101 irplib_test_eq( cpl_error_get_code(), CPL_ERROR_NONE ); 00102 00103 IRPLIB_TEST_END; 00104 } 00105
1.4.6