GRAVI Pipeline Reference Manual 1.9.4
Loading...
Searching...
No Matches
gravi-test.h
Go to the documentation of this file.
1/* $Id: gravi_data-test.c,v 1.59 2011/08/16 17:43:49 nazouaoui Exp $
2 *
3 * This file is part of the ESO Common Pipeline Library
4 * Copyright (C) 2001-2008 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21
22/*
23 * gravi-test.c
24 *
25 * Created on: 17 août 2011
26 * Author: nabih
27 */
28
29#ifndef GRAVI_TEST_C
30#define GRAVI_TEST_C
31
32
33#ifdef HAVE_CONFIG_H
34#include <config.h>
35#endif
36
37
38#include <stdio.h>
39#include <stdlib.h>
40#include <string.h>
41#include <math.h>
42
43#include <assert.h>
44
45#include <cpl_test.h>
46#include <cpl.h>
47#include <gravi_data.h>
48
49/* *+
50
51The VERBOSE macro is no longer used, instead
52export CPL_MSG_LEVEL=info
53can be used at run-time.
54(At compile time, the default message level can be
55controlled via cpl_test_init()).
56
57#define VERBOSE
58+* */
59
60/*
61 * Test for functions returning a generic pointer to data.
62 *
63 * r = variable to store returned pointer to data - expected non-NULL
64 * f = function call
65 * m = message
66 */
67
68
69
70#define test_data(r,f,m, flag) \
71 do { \
72 cpl_msg_info("test_data", "%s", m); \
73 r = f; \
74 cpl_assert(r != NULL); \
75 if (cpl_error_get_code() != CPL_ERROR_NONE) flag=EXIT_FAILURE; \
76 cpl_test_error(CPL_ERROR_NONE); \
77 } while (0) \
78
79
80/*
81 * Test for functions returning 0 on success.
82 *
83 * f = function call
84 * m = message
85 */
86
87#define test(f,m, flag) \
88 do { \
89 cpl_msg_info("test", "%s", m); \
90 cpl_test_zero(f); \
91 if (cpl_error_get_code() != CPL_ERROR_NONE) flag=EXIT_FAILURE; \
92 cpl_test_error(CPL_ERROR_NONE); \
93 } while (0)
94
95/*
96 * Test for expected failure in functions returning 0 on success.
97 *
98 * e = expected error code
99 * f = function call
100 * m = message
101 */
102
103#define test_failure(e,f,m, flag) \
104 do { \
105 cpl_msg_info("test_failure", "%s", m); \
106 if (cpl_error_get_code() != e) flag=EXIT_FAILURE; \
107 cpl_test_eq_error(f, e); \
108 } while (0)
109
110/*
111 * Test for expected failure in functions returning a pointer on success.
112 *
113 * e = expected error code
114 * f = function call
115 * m = message
116 */
117
118#define test_pfailure(e,f,m,flag) \
119 do { \
120 cpl_msg_info("test_failure", "%s", m); \
121 f; \
122 cpl_error_code err = cpl_error_get_code (); \
123 cpl_test_eq_error(err, e); \
124 if (err != e) flag=EXIT_FAILURE; \
125 } while (0)
126
127
128/*
129 * Test for functions returning an expected integer value.
130 *
131 * e = expected value
132 * f = function call
133 * m = message
134 */
135
136#define test_ivalue(e,f,m, flag) \
137 do { \
138 cpl_msg_info("test_ivalue", "%s", m); \
139 cpl_test_eq(f, e); \
140 if (f != e) flag = EXIT_FAILURE; \
141 cpl_test_error(CPL_ERROR_NONE); \
142 } while (0)
143
144/*
145 * Test for functions returning an expected pointer value.
146 *
147 * e = expected value
148 * f = function call
149 * m = message
150 */
151
152#define test_pvalue(e,f,m, flag) \
153 do { \
154 cpl_msg_info("test_pvalue", "%s", m); \
155 cpl_test_eq_ptr(f, e); \
156 if (cpl_error_get_code() != CPL_ERROR_NONE) flag = EXIT_FAILURE; \
157 cpl_test_error(CPL_ERROR_NONE); \
158 } while (0)
159
160/*
161 * Test for functions returning an expected floating point value.
162 *
163 * e = expected value
164 * t = tolerance on expected value
165 * f = function call
166 * m = message
167 */
168
169#define test_fvalue(e,t,f,m, flag) \
170 do { \
171 cpl_msg_info("test_fvalue", "%s", m); \
172 cpl_test_abs(f, e, t); \
173 if (cpl_error_get_code() != CPL_ERROR_NONE) flag = EXIT_FAILURE; \
174 cpl_test_error(CPL_ERROR_NONE); \
175 } while (0)
176
177/*
178 * Test for functions returning an expected complex value.
179 *
180 * e = expected value
181 * t = tolerance on expected value
182 * f = function call
183 * m = message
184 */
185
186#define test_cvalue(e,t,f,m, flag) \
187 do { \
188 cpl_msg_info("test_cvalue", "%s", m); \
189 cpl_test_abs_complex(f, e, t); \
190 if (cpl_error_get_code() != CPL_ERROR_NONE) flag = EXIT_FAILURE; \
191 cpl_test_error(CPL_ERROR_NONE); \
192 } while (0)
193
194/*
195 * Test for functions returning an expected character string.
196 *
197 * e = expected value
198 * f = function call
199 * m = message
200 */
201
202#define test_svalue(e,f,m, flag) \
203 do { \
204 cpl_msg_info("test_svalue", "%s", m); \
205 cpl_test_eq_string(f, e); \
206 if (cpl_error_get_code() != CPL_ERROR_NONE) flag = EXIT_FAILURE; \
207 cpl_test_error(CPL_ERROR_NONE); \
208 } while (0)
209
210#define GRAVI_INS_TRAIN_EXT_NAME "INS_TRAIN"
211#define GRAVI_INS_DESC_EXT_NAME "INS_DESCRIPTION"
212#define GRAVI_PRIMARY_HDR_EXT "PRIMARY_HDR"
213#define GRAVI_IMAGING_DATA_NAME_EXT "IMAGING_DATA"
214#define GRAVI_IMAGING_DETECTOR_NAME_EXT "IMAGING_DETECTOR"
215
216int gravi_array_compare(cpl_array * , cpl_array * );
217int gravi_table_compare(cpl_table *, cpl_table *);
218int gravi_propertylist_compare(cpl_propertylist *, cpl_propertylist *);
220
221
222#endif
223
int gravi_propertylist_compare(cpl_propertylist *, cpl_propertylist *)
Definition: gravi-test.c:346
int gravi_table_compare(cpl_table *, cpl_table *)
Definition: gravi-test.c:210
int gravi_data_compare(gravi_data *, gravi_data *)
Definition: gravi-test.c:436
int gravi_array_compare(cpl_array *, cpl_array *)
Definition: gravi-test.c:42
typedefCPL_BEGIN_DECLS struct _gravi_data_ gravi_data
Definition: gravi_data.h:39