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_framelist.h> 00029 00030 00031 /*----------------------------------------------------------------------------*/ 00035 /*----------------------------------------------------------------------------*/ 00036 00037 00038 /*----------------------------------------------------------------------------*/ 00042 /*----------------------------------------------------------------------------*/ 00043 00044 int main(void) 00045 { 00046 00047 irplib_framelist * flist; 00048 irplib_framelist * nulllist; 00049 cpl_frame * frm; 00050 cpl_frameset * fset; 00051 cpl_frameset * nullset; 00052 int i; 00053 00054 /* Initialize CPL for unit testing */ 00055 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING); 00056 00057 /* Some NULL tests */ 00058 00059 irplib_framelist_delete(NULL); 00060 cpl_test_error(CPL_ERROR_NONE); 00061 00062 nulllist = irplib_framelist_cast(NULL); 00063 cpl_test_error(CPL_ERROR_NULL_INPUT); 00064 cpl_test_null(nulllist); 00065 00066 nullset = irplib_frameset_cast(NULL); 00067 cpl_test_error(CPL_ERROR_NULL_INPUT); 00068 cpl_test_null(nullset); 00069 00070 irplib_framelist_empty(NULL); 00071 cpl_test_error(CPL_ERROR_NONE); 00072 00073 i = irplib_framelist_get_size(NULL); 00074 cpl_test_error(CPL_ERROR_NULL_INPUT); 00075 cpl_test_leq(i, -1); 00076 00077 00078 /* Some tests on an empty list */ 00079 flist = irplib_framelist_new(); 00080 00081 cpl_test_zero(irplib_framelist_get_size(flist)); 00082 00083 irplib_framelist_empty(flist); 00084 00085 cpl_test_zero(irplib_framelist_get_size(flist)); 00086 00087 fset = irplib_frameset_cast(flist); 00088 00089 irplib_framelist_delete(flist); 00090 00091 flist = irplib_framelist_cast(fset); 00092 00093 cpl_test_zero(irplib_framelist_get_size(flist)); 00094 00095 irplib_framelist_delete(flist); 00096 00097 frm = cpl_frame_new(); 00098 cpl_frame_set_filename(frm, "test.fits"); 00099 cpl_frame_set_tag(frm, "TEST"); 00100 cpl_frameset_insert(fset, frm); 00101 00102 flist = irplib_framelist_cast(fset); 00103 00104 cpl_test_eq(irplib_framelist_get_size(flist), 1); 00105 00106 irplib_framelist_delete(flist); 00107 00108 cpl_frameset_insert(fset, cpl_frame_duplicate(frm)); 00109 flist = irplib_framelist_cast(fset); 00110 00111 cpl_test_eq(irplib_framelist_get_size(flist), 2); 00112 00113 cpl_frameset_delete(fset); 00114 irplib_framelist_delete(flist); 00115 00116 return cpl_test_end(0); 00117 }