irplib_cat-test.c
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifdef HAVE_CONFIG_H
00032 #include <config.h>
00033 #endif
00034
00035 #include <cpl_test.h>
00036
00037 #include "irplib_cat.h"
00038
00039 #if defined CPL_VERSION_CODE && CPL_VERSION_CODE >= CPL_VERSION(4, 8, 0)
00040
00041
00042
00043 static void irplib_cat_all_test(void);
00044
00045
00046
00047
00048 int main (void)
00049 {
00050
00051 cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING);
00052
00053 irplib_cat_all_test();
00054
00055 return cpl_test_end(0);
00056 }
00057
00058 static void irplib_cat_all_test(void)
00059 {
00060 cpl_propertylist * prop_wcs;
00061 cpl_wcs * wcs = NULL;
00062 double ra1, ra2, dec1, dec2;
00063
00064
00065 prop_wcs = cpl_propertylist_new();
00066 cpl_test_nonnull(prop_wcs);
00067 cpl_propertylist_append_double(prop_wcs, "CRVAL1", 0.);
00068 cpl_propertylist_append_double(prop_wcs, "CRVAL2", 0.);
00069 cpl_propertylist_append_int(prop_wcs, "CRPIX1", 1);
00070 cpl_propertylist_append_int(prop_wcs, "CRPIX2", 1);
00071 cpl_propertylist_append_double(prop_wcs, "CD1_1", .001);
00072 cpl_propertylist_append_double(prop_wcs, "CD1_2", 0.);
00073 cpl_propertylist_append_double(prop_wcs, "CD2_1", 00.);
00074 cpl_propertylist_append_double(prop_wcs, "CD2_2", .001);
00075 cpl_propertylist_append_int(prop_wcs, "NAXIS", 2);
00076 cpl_propertylist_append_int(prop_wcs, "NAXIS1", 1000);
00077 cpl_propertylist_append_int(prop_wcs, "NAXIS2", 1000);
00078 wcs = cpl_wcs_new_from_propertylist(prop_wcs);
00079 if(cpl_error_get_code() == CPL_ERROR_NO_WCS)
00080 {
00081 cpl_msg_warning(__func__,"No WCS present. Tests disabled");
00082 cpl_test_error(CPL_ERROR_NO_WCS);
00083 cpl_test_null(wcs);
00084 cpl_propertylist_delete(prop_wcs);
00085 return;
00086 }
00087 cpl_test_nonnull(wcs);
00088
00089 irplib_cat_get_image_limits(wcs, 0., &ra1, &ra2, &dec1, &dec2);
00090 cpl_test_error(CPL_ERROR_NONE);
00091 cpl_test_leq(ra1 - 0.00, DBL_EPSILON);
00092 cpl_test_leq(ra2 - 0.99, DBL_EPSILON);
00093 cpl_test_leq(dec1 - 0.00, DBL_EPSILON);
00094 cpl_test_leq(dec2 - 0.99, DBL_EPSILON);
00095
00096
00097
00098 cpl_wcs_delete(wcs);
00099 cpl_propertylist_delete(prop_wcs);
00100 }
00101 #endif