/* $Id: cpl_fits-test.c,v 1.8 2007/11/28 15:31:27 yjung Exp $ * * This file is part of the ESO Common Pipeline Library * Copyright (C) 2001-2004 European Southern Observatory * * 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 * the Free Software Foundation; either version 2 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 General Public License for more details. * * You should have received a copy of the GNU 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 */ /* * $Author: yjung $ * $Date: 2007/11/28 15:31:27 $ * $Revision: 1.8 $ * $Name: $ */ /*----------------------------------------------------------------------------- Includes -----------------------------------------------------------------------------*/ #include #include #include "cpl_fits.h" #include "cpl_propertylist.h" #include "cpl_test.h" #include "cpl_msg.h" #include "cpl_image.h" #include "cpl_table.h" #include "cpl_propertylist.h" /*----------------------------------------------------------------------------- Main -----------------------------------------------------------------------------*/ int main(void) { cpl_image * ima ; cpl_table * tab ; cpl_propertylist * pl ; const char * filename = "cpl_fits-test.fits" ; /* Initialise */ cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING); /* Insert tests below */ cpl_msg_info("", "Tests for FITS basic routines"); /* First create a test MEF */ ima = cpl_image_fill_test_create(5, 5); tab = cpl_table_new(5) ; cpl_table_new_column(tab, "test", CPL_TYPE_FLOAT) ; /* Empty primary unit */ pl = cpl_propertylist_new() ; cpl_propertylist_update_string(pl, "TESTKEY", "TESTVAL") ; cpl_propertylist_save(pl, filename, CPL_IO_DEFAULT) ; cpl_propertylist_delete(pl) ; /* Table in the first extension */ pl = cpl_propertylist_new() ; cpl_propertylist_update_string(pl, "EXTNAME", "EXT1") ; cpl_table_save(tab, NULL, pl, filename, CPL_IO_EXTEND) ; cpl_propertylist_delete(pl) ; /* Image in the second extension */ pl = cpl_propertylist_new() ; cpl_propertylist_update_string(pl, "EXTNAME", "EXT2") ; cpl_image_save(ima, filename, 32, pl, CPL_IO_EXTEND) ; cpl_propertylist_delete(pl) ; /* Empty extension 3 */ pl = cpl_propertylist_new() ; cpl_propertylist_update_string(pl, "EXTNAME", "EXT3") ; cpl_propertylist_save(pl, filename, CPL_IO_EXTEND) ; cpl_propertylist_delete(pl) ; /* Table in extension 4 */ pl = cpl_propertylist_new() ; cpl_propertylist_update_string(pl, "EXTNAME", "EXT4") ; cpl_table_save(tab, NULL, pl, filename, CPL_IO_EXTEND) ; cpl_propertylist_delete(pl) ; /* Free */ cpl_image_delete(ima) ; cpl_table_delete(tab) ; /* Empty extension 5 */ cpl_propertylist_save(NULL, filename, CPL_IO_EXTEND) ; /* Get the number of extensions */ cpl_test(cpl_fits_get_nb_extensions(filename) == 5); /* Get the image extension number */ cpl_test(cpl_fits_get_extension_nb(filename, "EXT3") == 3) ; /* End of tests */ remove(filename) ; return cpl_test_end(0); }