Debian Codegraph @

testing/fulltests/unit-tests/T010netsnmp_string_time_to_secs_clib.c

raw
1 /* HEADER Testing the netsnmp_string_time_to_secs API */
2
3 #ifndef NETSNMP_FEATURE_REMOVE_STRING_TIME_TO_SECS
4
5 int secs;
6
7 #define TESTIT(x,y) \
8 OKF(y == (secs = netsnmp_string_time_to_secs(x)), \
9 ("netsnmp_string_time_to_secs of %s returned %d, not 5", x, secs))
10
11 TESTIT("5", 5);
12 TESTIT("5", 5);
13
14 TESTIT("5s", 5);
15 TESTIT("5S", 5);
16
17 TESTIT("5m", 5 * 60);
18 TESTIT("5M", 5 * 60);
19
20 TESTIT("5h", 5 * 60 * 60);
21 TESTIT("5H", 5 * 60 * 60);
22
23 TESTIT("5d", 5 * 60 * 60 * 24);
24 TESTIT("5D", 5 * 60 * 60 * 24);
25
26 TESTIT("5w", 5 * 60 * 60 * 24 * 7);
27 TESTIT("5W", 5 * 60 * 60 * 24 * 7);
28
29 /* now with longer times */
30 TESTIT("1234", 1234);
31 TESTIT("1234", 1234);
32
33 TESTIT("1234s", 1234);
34 TESTIT("1234S", 1234);
35
36 TESTIT("1234m", 1234 * 60);
37 TESTIT("1234M", 1234 * 60);
38
39 TESTIT("1234h", 1234 * 60 * 60);
40 TESTIT("1234H", 1234 * 60 * 60);
41
42 TESTIT("1234d", 1234 * 60 * 60 * 24);
43 TESTIT("1234D", 1234 * 60 * 60 * 24);
44
45 TESTIT("1234w", 1234 * 60 * 60 * 24 * 7);
46 TESTIT("1234W", 1234 * 60 * 60 * 24 * 7);
47
48 #endif