FORS Pipeline Reference Manual  4.12.5
test.h
1 /* *
2  * This file is part of the ESO IRPLIB package *
3  * Copyright (C) 2004,2005 European Southern Observatory *
4  * *
5  * This library is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA *
18  * */
19 
20 #ifndef TEST_H
21 #define TEST_H
22 
23 #ifdef HAVE_CONFIG_H
24 # include <config.h>
25 #endif
26 
27 /*-----------------------------------------------------------------------------
28  Includes
29  -----------------------------------------------------------------------------*/
30 
31 #include <cpl.h>
32 
33 /*-----------------------------------------------------------------------------
34  Defines
35  -----------------------------------------------------------------------------*/
36 
39 /*----------------------------------------------------------------------------*/
55 /*----------------------------------------------------------------------------*/
56 #define test(expr) \
57  test_macro(expr, #expr, cpl_func, __FILE__, __LINE__)
58 
59 /*----------------------------------------------------------------------------*/
79 /*----------------------------------------------------------------------------*/
80 #define test_eq(first, second) \
81  test_eq_macro(first, #first, second, #second, \
82  cpl_func, __FILE__, __LINE__)
83 /*----------------------------------------------------------------------------*/
99 /*----------------------------------------------------------------------------*/
100 #define test_eq_string(first, second) \
101  test_eq_string_macro(first, #first, second, #second, \
102  cpl_func, __FILE__, __LINE__)
103 
104 /*----------------------------------------------------------------------------*/
123 /*----------------------------------------------------------------------------*/
124 #define test_abs(first, second, tolerance) \
125  test_abs_macro(first, #first, second, #second, \
126  tolerance, #tolerance, \
127  cpl_func, __FILE__, __LINE__)
128 
129 /*----------------------------------------------------------------------------*/
154 /*----------------------------------------------------------------------------*/
155 #define test_rel(first, second, tolerance) \
156  test_rel_macro(first, #first, second, #second, \
157  tolerance, #tolerance, \
158  cpl_func, __FILE__, __LINE__)
159 
160 /*----------------------------------------------------------------------------*/
165 /*----------------------------------------------------------------------------*/
166 #define TEST_INIT test_init_macro(__FILE__)
167 
168 /*----------------------------------------------------------------------------*/
173 /*----------------------------------------------------------------------------*/
174 #define TEST_END \
175  return(test_end_macro(cpl_func, __FILE__, __LINE__) ? \
176  EXIT_FAILURE : EXIT_SUCCESS)
177 
178 
179 /*-----------------------------------------------------------------------------
180  Functions prototypes
181  -----------------------------------------------------------------------------*/
182 /* None of these functions should be called directly */
183 void
184 test_init_macro(const char *file);
185 
186 unsigned
187 test_end_macro(const char *function, const char *file, unsigned line);
188 
189 void
190 test_macro(int expression, const char *expr_string,
191  const char *function, const char *file, unsigned line);
192 
193 void
194 test_eq_macro(int first, const char *first_string,
195  int second, const char *second_string,
196  const char *function, const char *file, unsigned line);
197 void
198 test_eq_string_macro(const char *first, const char *first_string,
199  const char *second, const char *second_string,
200  const char *function,
201  const char *file, unsigned line);
202 void
203 test_abs_macro(double first, const char *first_string,
204  double second, const char *second_string,
205  double tolerance, const char *tolerance_string,
206  const char *function, const char *file, unsigned line);
207 
208 void
209 test_rel_macro(double first, const char *first_string,
210  double second, const char *second_string,
211  double tolerance, const char *tolerance_string,
212  const char *function, const char *file, unsigned line);
213 
214 void
215 test_recipe_output(const cpl_frameset *frames,
216  const char *const product_tags[], int n_prod,
217  const char *main_product,
218  const char *const qc[], int n_qc);
219 
222 #endif
void test_macro(int expression, const char *expr_string, const char *function, const char *file, unsigned line)
Test a given expression.
Definition: test.c:112
void test_abs_macro(double first, const char *first_string, double second, const char *second_string, double tolerance, const char *tolerance_string, const char *function, const char *file, unsigned line)
Test if two numerical expressions are within a given (absolute) tolerance.
Definition: test.c:208
void test_eq_macro(int first, const char *first_string, int second, const char *second_string, const char *function, const char *file, unsigned line)
Test if two integer expressions are equal.
Definition: test.c:139
void test_rel_macro(double first, const char *first_string, double second, const char *second_string, double tolerance, const char *tolerance_string, const char *function, const char *file, unsigned line)
Test if two numerical expressions are within a given relative tolerance.
Definition: test.c:245
unsigned test_end_macro(const char *function, const char *file, unsigned line)
Perform the final checks and return the number of errors.
Definition: test.c:381
void test_eq_string_macro(const char *first, const char *first_string, const char *second, const char *second_string, const char *function, const char *file, unsigned line)
Test if two strings are equal.
Definition: test.c:170
void test_init_macro(const char *file)
Initialize CPL + messaging.
Definition: test.c:290
void test_recipe_output(const cpl_frameset *frames, const char *const product_tags[], int n_prod, const char *main_product, const char *const qc[], int n_qc)
Test existence of recipe products.
Definition: test.c:428