/* $Id: cpl_test-test.c,v 1.8 2008/02/07 10:22:19 llundin 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: llundin $ * $Date: 2008/02/07 10:22:19 $ * $Revision: 1.8 $ * $Name: $ */ /*----------------------------------------------------------------------------- Includes -----------------------------------------------------------------------------*/ #ifdef HAVE_CONFIG_H #include #endif #include #include #include /*----------------------------------------------------------------------------- Main -----------------------------------------------------------------------------*/ int main(void) { int nxfail = 0; /* The number of expected failures */ cpl_msg_severity level; cpl_test_init(PACKAGE_BUGREPORT, CPL_MSG_WARNING); cpl_test(41); cpl_test_zero(0); cpl_test_null(NULL); cpl_test_nonnull(cpl_func); cpl_test_eq(1, 1); cpl_test_error(CPL_ERROR_NONE); /* Set a CPL error */ (void)cpl_msg_set_log_name(NULL); cpl_test_error(CPL_ERROR_NULL_INPUT); cpl_test_noneq(0, 1); cpl_test_eq_string("", ""); cpl_test_eq_string(cpl_func, cpl_func); cpl_test_abs(0.0, 0.0, 0.0); cpl_test_abs(0.0, 1.0, 1.0); cpl_test_abs(1.0, 0.0, 1.0); cpl_test_rel(0.0, 0.0, 0.0); cpl_test_rel(1.0, 1.0, 0.0); cpl_test_rel(-1.0, -2.0, 1.0); cpl_test_rel(-2.0, -1.0, 1.0); /* Turn off messaging during testing of expected failures */ level = cpl_msg_get_level(); cpl_msg_set_level(CPL_MSG_OFF); cpl_test(0); nxfail++; cpl_test_zero(41); nxfail++; cpl_test_null(cpl_func); nxfail++; cpl_test_nonnull(NULL); nxfail++; cpl_test_error(CPL_ERROR_EOL); nxfail++; /* Set a CPL error */ (void)cpl_msg_set_log_name(NULL); cpl_test_error(CPL_ERROR_NONE); nxfail++; cpl_test_eq(0, 1); nxfail++; cpl_test_noneq(0, 0); nxfail++; cpl_test_eq_string("A", "B"); nxfail++; cpl_test_eq_string(NULL, ""); nxfail++; cpl_test_eq_string(NULL, NULL); nxfail++; cpl_test_abs(0.0, 0.0, -1.0); nxfail++; cpl_test_abs(0.0, 2.0, 1.0); nxfail++; cpl_test_abs(2.0, 0.0, 1.0); nxfail++; cpl_test_rel(0.0, 0.0, -1.0); nxfail++; cpl_test_rel(0.0, 1.0, 1.0); nxfail++; cpl_test_rel(1.0, 0.0, 1.0); nxfail++; cpl_test_rel(1.0, 3.0, 1.0); nxfail++; /* Tests done - reinstate normal messaging */ cpl_msg_set_level(level); return cpl_test_end(-nxfail); }