blob: 96803ad67ec9591a99a2684f9b5a376086e4e654 [file] [log] [blame]
Lev Walkin535612a2005-07-03 05:32:40 +00001#define __ASN_INTERNAL_TEST_MODE__
Lev Walkin44212662004-08-19 13:26:54 +00002#include <GeneralizedTime.c>
Lev Walkina460ba32004-10-20 15:40:04 +00003#include <UTCTime.c>
Lev Walkin44212662004-08-19 13:26:54 +00004#include <constraints.c>
Lev Walkinf15320b2004-06-03 03:38:44 +00005
6static void
Lev Walkin0aca3852004-08-07 03:51:43 +00007check(char *time_str, time_t sample, int as_gmt) {
Lev Walkinf15320b2004-06-03 03:38:44 +00008 UTCTime_t gt;
9 struct tm tm;
10 time_t tloc;
11
Lev Walkin535612a2005-07-03 05:32:40 +000012 gt.buf = (uint8_t *)time_str;
Lev Walkinf15320b2004-06-03 03:38:44 +000013 gt.size = strlen(time_str);
14
Lev Walkin0aca3852004-08-07 03:51:43 +000015 tloc = asn_UT2time(&gt, &tm, as_gmt);
Lev Walkinf15320b2004-06-03 03:38:44 +000016 printf("[%s] -> %ld == %ld\n", time_str, (long)tloc, (long)sample);
17 if(tloc != -1)
18 printf("\t%d-%d-%dT%02d:%02d:%02d %ld\n",
19 tm.tm_year + 1900,
20 tm.tm_mon + 1,
21 tm.tm_mday,
22 tm.tm_hour,
23 tm.tm_min,
24 tm.tm_sec,
Lev Walkina460ba32004-10-20 15:40:04 +000025 GMTOFF(tm)
Lev Walkinf15320b2004-06-03 03:38:44 +000026 );
27 assert(tloc == sample);
Lev Walkin0aca3852004-08-07 03:51:43 +000028
Lev Walkina460ba32004-10-20 15:40:04 +000029 assert(tloc == -1 || as_gmt == 0 || GMTOFF(tm) == 0);
Lev Walkin0aca3852004-08-07 03:51:43 +000030
31 if(as_gmt) check(time_str, sample, as_gmt);
Lev Walkinf15320b2004-06-03 03:38:44 +000032}
33
34int
35main(int ac, char **av) {
36
Lev Walkin44212662004-08-19 13:26:54 +000037 (void)av;
38
Lev Walkin0aca3852004-08-07 03:51:43 +000039 check("0401250", -1, 0);
40 check("0401250930", -1, 0); /* "Z" or "(+|-)hhmm" required */
41 check("04012509300", -1, 0);
42 check("040125093000-", -1, 0);
43 check("040125093007-0", -1, 0);
44 check("040125093007-080", -1, 0);
45 check("0401250930.01Z", -1, 0);
Lev Walkinf15320b2004-06-03 03:38:44 +000046
Lev Walkin0aca3852004-08-07 03:51:43 +000047 check("040125093007Z", 1075023007, 0);
48 check("040125093007+00", 1075023007, 0);
49 check("040125093007-0800", 1075051807, 0);
Lev Walkinf15320b2004-06-03 03:38:44 +000050
51 if(ac > 1) {
52 /* These will be valid only inside PST time zone */
Lev Walkin0aca3852004-08-07 03:51:43 +000053 check("040125093007", 1075051807, 0);
54 check("040125093000,01", 1075051800, 0);
55 check("040125093000,1234", 1075051800, 0);
Lev Walkinf15320b2004-06-03 03:38:44 +000056 }
57
58 return 0;
59}
Lev Walkin0aca3852004-08-07 03:51:43 +000060
61
62/*
63 * Dummy function.
64 */
65
Lev Walkina9cc46e2004-09-22 16:06:28 +000066asn_enc_rval_t
Lev Walkin5e033762004-09-29 13:26:15 +000067OCTET_STRING_encode_der(asn_TYPE_descriptor_t *td, void *ptr, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkina9cc46e2004-09-22 16:06:28 +000068 asn_enc_rval_t erval;
Lev Walkin44212662004-08-19 13:26:54 +000069
70 (void)td;
71 (void)ptr;
72 (void)tag_mode;
73 (void)tag;
74 (void)cb;
75 (void)app_key;
76
Lev Walkin0aca3852004-08-07 03:51:43 +000077 return erval;
78}
Lev Walkina9cc46e2004-09-22 16:06:28 +000079
80asn_enc_rval_t
Lev Walkindc06f6b2004-10-20 15:50:55 +000081OCTET_STRING_encode_xer_utf8(asn_TYPE_descriptor_t *td, void *ptr, int ilevel, enum xer_encoder_flags_e flags, asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkina9cc46e2004-09-22 16:06:28 +000082 asn_enc_rval_t erval;
83
84 (void)td;
85 (void)ptr;
86 (void)ilevel;
87 (void)flags;
88 (void)cb;
89 (void)app_key;
90
91 return erval;
92}