annotate tests/test-parse-duration.c @ 40057:b06060465f09

maint: Run 'make update-copyright'
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 01 Jan 2019 00:25:11 +0100
parents 10eb9086bea0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10823
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
1 /* Test of parsing durations.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2008-2019 Free Software Foundation, Inc.
10823
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
3
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
7 (at your option) any later version.
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
8
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
12 GNU General Public License for more details.
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
13
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
10823
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
16
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
17 #include <config.h>
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
18
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
19 #include <errno.h>
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
20 #include <stdio.h>
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
21 #include <stdlib.h>
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
22 #include <string.h>
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
23 #include <time.h>
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
24 #include <unistd.h>
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
25
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
26 #include "parse-duration.h"
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
27
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
28 int
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
29 main (int argc, char *argv[])
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
30 {
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
31 if (--argc <= 0)
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
32 {
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
33 fprintf (stderr, "USAGE: %s <time-spec> [...]", argv[0]);
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
34 return 1;
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
35 }
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
36
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
37 do
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
38 {
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
39 char const * arg = *++argv;
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
40 time_t res = parse_duration (arg);
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
41 if (errno != 0)
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
42 {
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
43 fprintf (stderr, "could not parse time: %s\n\terr %d - %s\n", arg,
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
44 errno, strerror (errno));
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
45 return 1;
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
46 }
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
47 printf ("%u\n", (unsigned int)res);
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
48 } while (--argc > 0);
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
49
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
50 return 0;
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
51 }
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
52
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
53 /*
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
54 * Local Variables:
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
55 * mode: C
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
56 * c-file-style: "gnu"
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
57 * indent-tabs-mode: nil
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
58 * End:
72f4e089ac91 Tests for module 'parse-duration'.
Bruce Korb <bkorb@gnu.org>
parents:
diff changeset
59 * end of parse-duration.c */