1 /* Test of getdate() function.
2 Copyright (C) 2008 Free Software Foundation, Inc.
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 3, or (at your option)
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.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /* Written by Simon Josefsson <simon@josefsson.org>, 2008. */
28 #define ASSERT(expr) \
33 fprintf (stderr, "%s:%d: assertion failed\n", \
34 __FILE__, __LINE__); \
42 #define LOG(str, now, res) \
43 printf ("string `%s' diff %d %d\n", \
44 str, res.tv_sec - now.tv_sec, res.tv_nsec - now.tv_nsec);
46 #define LOG(str, now, res) 0
50 main (int argc, char **argv)
53 struct timespec result;
60 ASSERT (get_date (&result, p, &now));
62 ASSERT (now.tv_sec == result.tv_sec && now.tv_nsec == result.tv_nsec);
67 ASSERT (get_date (&result, p, &now));
69 ASSERT (now.tv_sec + 24 * 60 * 60 == result.tv_sec
70 && now.tv_nsec == result.tv_nsec);
75 ASSERT (get_date (&result, p, &now));
77 ASSERT (now.tv_sec - 24 * 60 * 60 == result.tv_sec
78 && now.tv_nsec == result.tv_nsec);
83 ASSERT (get_date (&result, p, &now));
85 ASSERT (now.tv_sec + 4 * 60 * 60 == result.tv_sec
86 && now.tv_nsec == result.tv_nsec);