Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LeapSecsTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 David Chin, Jolien Creighton
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 <stdio.h>
21#include <math.h>
22#include <stdlib.h>
23#include <time.h>
24
25#include <lal/LALStdlib.h>
26#include <lal/Date.h>
27
29
30static int do_test(int gpssec, int tai_utc_before, int tai_utc_after)
31{
32 int result = 0;
33 int lal_tai_utc;
34
35 if(lalDebugLevel > 2)
36 printf("TestLeapSecs: BEFORE LEAP SECOND ADDED\n");
37 lal_tai_utc = XLALLeapSeconds(gpssec - 1);
38 if(lalDebugLevel > 0)
39 printf("\tGPS = %9d; TAI-UTC = %d\n", gpssec - 1, lal_tai_utc);
40
41 if(XLALGetBaseErrno() && lalDebugLevel > 0) {
43 result = -1;
44 }
45 if(lal_tai_utc != tai_utc_before) {
46 if(lalDebugLevel > 0)
47 fprintf(stderr, "TestLeapSecs: XLALLeapSeconds() returned wrong value: expected %d, got %d\n", tai_utc_before, lal_tai_utc);
48 result = -1;
49 }
50
51 if(lalDebugLevel > 2)
52 printf("TestLeapSecs: AFTER LEAP SECOND ADDED\n");
53 lal_tai_utc = XLALLeapSeconds(gpssec);
54 if(lalDebugLevel > 0)
55 printf("\tGPS = %9d; TAI-UTC = %d\n\n", gpssec, lal_tai_utc);
56
57 if(XLALGetBaseErrno() && lalDebugLevel > 0) {
59 result = -1;
60 }
61 if(lal_tai_utc != tai_utc_after) {
62 if(lalDebugLevel > 0)
63 fprintf(stderr, "TestLeapSecs: XLALLeapSeconds() returned wrong value: expected %d, got %d\n", tai_utc_after, lal_tai_utc);
64 result = -1;
65 }
66 return result;
67}
68
69
70int main(void)
71{
72 int i;
73
74 for(i = 1; i < numleaps; i++)
75 do_test(leaps[i].gpssec, leaps[i-1].taiutc, leaps[i].taiutc);
76
77 return 0;
78}
static int do_test(int gpssec, int tai_utc_before, int tai_utc_after)
Definition: LeapSecsTest.c:30
int main(void)
Definition: LeapSecsTest.c:70
#define fprintf
static const struct leaps_table leaps[]
static const int numleaps
#define lalDebugLevel
Definition: LALDebugLevel.h:58
int XLALLeapSeconds(INT4 gpssec)
Returns the leap seconds TAI-UTC at a given GPS second.
int XLALGetBaseErrno(void)
Gets the XLAL base error number ignoring the internal-function-failed flag.
Definition: XLALError.c:356
#define XLAL_PERROR()
Prints an error message for the current value of xlalErrno.
Definition: XLALError.h:485