Loading [MathJax]/extensions/TeX/AMSmath.js
LALPulsar 7.1.1.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
DopplerScanTest.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Reinhard Prix
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19
20#include <math.h>
21
22#include <lal/LALMalloc.h>
23#include <lal/DopplerScan.h>
24#include <lal/DopplerFullScan.h>
25
26/**
27 * \author Reinhard Prix
28 * \file
29 * \brief Tests for exported functions in Doppler[Full]Scan
30 *
31 */
32
33// ---------- defines --------------------
34
35// ---------- Macros --------------------
36// ---------- global variables --------------------
37
38// ---------- local prototypes
39static int test_XLALParseSkyRegionString( void );
40static int compareSkyPosition( SkyPosition *pos1, SkyPosition *pos2, REAL8 tol );
41// ---------- function definitions --------------------
42
43/**
44 * MAIN function: calls a number of unit-tests
45 */
46int main( void )
47{
48
50
51 /* check for memory leaks */
53
54 /* all tests passed */
55 return XLAL_SUCCESS;
56
57} /* main() */
58
59
60/**
61 * Unit test for XLALParseSkyRegionString()
62 */
63static int
65{
66
67 const char *skyRegionString1 = "(10:25:1.1, -5:30:44.123), (1:2:3.45, 2:33:15), (5:0:0, 0:0:0 )";
68 const char *skyRegionString2 = "(2.72715695049852,-0.0962070232002041),(0.270776925139095,0.0445786179780218),(1.30899693899575,0)";
69
70 SkyRegion XLAL_INIT_DECL( skyRegion1 );
71 SkyRegion XLAL_INIT_DECL( skyRegion2 );
72
73 XLAL_CHECK( XLALParseSkyRegionString( &skyRegion1, skyRegionString1 ) == XLAL_SUCCESS, XLAL_EFUNC );
74 XLAL_CHECK( XLALParseSkyRegionString( &skyRegion2, skyRegionString2 ) == XLAL_SUCCESS, XLAL_EFUNC );
75
76 XLAL_CHECK( skyRegion1.numVertices == skyRegion2.numVertices, XLAL_EFAILED );
77
78 REAL8 tol = 5e-15;
79 XLAL_CHECK( compareSkyPosition( &skyRegion1.lowerLeft, &skyRegion2.lowerLeft, tol ) == XLAL_SUCCESS, XLAL_EFUNC );
80 XLAL_CHECK( compareSkyPosition( &skyRegion1.upperRight, &skyRegion2.upperRight, tol ) == XLAL_SUCCESS, XLAL_EFUNC );
81 for ( UINT4 i = 0; i < skyRegion1.numVertices; i ++ ) {
82 XLAL_CHECK( compareSkyPosition( &skyRegion1.vertices[i], &skyRegion2.vertices[i], tol ) == XLAL_SUCCESS, XLAL_EFUNC );
83 }
84
85 XLALFree( skyRegion1.vertices );
86 XLALFree( skyRegion2.vertices );
87
88 return XLAL_SUCCESS;
89
90} // test_XLALParseSkyRegionString()
91
92static int
94{
95 XLAL_CHECK( ( pos1 != NULL ) && ( pos2 != NULL ), XLAL_EINVAL );
96
97 REAL8 diff;
98 XLAL_CHECK( pos1->system == pos2->system, XLAL_EINVAL );
99 XLAL_CHECK( ( diff = fabs( pos1->longitude - pos2->longitude ) ) < tol, XLAL_ETOL, "Longitude %.16g differs from %.16g by %.2g exceeding tolerance %.2g\n",
100 pos1->longitude, pos2->longitude, diff, tol );
101 XLAL_CHECK( ( diff = fabs( pos1->latitude - pos2->latitude ) ) < tol, XLAL_ETOL, "Latitude %.16g differs from %.16g by %.2g exceeding tolerance %.2g\n",
102 pos1->latitude, pos2->latitude, diff, tol );
103
104 return XLAL_SUCCESS;
105} // compareSkyPosition()
int XLALParseSkyRegionString(SkyRegion *region, const CHAR *input)
parse a skyRegion-string into a SkyRegion structure: the expected string-format is " (longitude1,...
Definition: DopplerScan.c:1203
static int test_XLALParseSkyRegionString(void)
Unit test for XLALParseSkyRegionString()
static int compareSkyPosition(SkyPosition *pos1, SkyPosition *pos2, REAL8 tol)
int main(void)
MAIN function: calls a number of unit-tests.
void LALCheckMemoryLeaks(void)
REAL8 tol
double e
double REAL8
#define XLAL_INIT_DECL(var,...)
uint32_t UINT4
void XLALFree(void *p)
#define XLAL_CHECK(assertion,...)
XLAL_SUCCESS
XLAL_EFUNC
XLAL_ETOL
XLAL_EINVAL
XLAL_EFAILED
REAL8 longitude
REAL8 latitude
CoordinateSystem system
structure describing a polygon-region in the sky
Definition: DopplerScan.h:108