test-http-date.c revision ba592dc74a004ad47dfe58edcfc1ca7297551e39
45312f52ff3a3d4c137447be4c7556500c2f8bf2Timo Sirainen/* Copyright (c) 2013-2014 Dovecot authors, see the included COPYING file */
1d4f710106fb498750456724628da6063e012e6dTimo Sirainen
1d4f710106fb498750456724628da6063e012e6dTimo Sirainen#include "test-lib.h"
9439bed2f07d6475febd8a247cd2f0990fb32a13Timo Sirainen#include "test-common.h"
d3d769026fae5d21c2d29614d3bc4579e8d79e81Timo Sirainen#include "http-date.h"
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen#include <time.h>
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
9439bed2f07d6475febd8a247cd2f0990fb32a13Timo Sirainenstruct http_date_test {
9439bed2f07d6475febd8a247cd2f0990fb32a13Timo Sirainen const char *date_in;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char *date_out;
9439bed2f07d6475febd8a247cd2f0990fb32a13Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen struct tm tm;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen};
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Valid date tests */
4ead43ecc06d10047998966c4dc0b142ecce4b66Timo Sirainenstatic const struct http_date_test valid_date_tests[] = {
1d4f710106fb498750456724628da6063e012e6dTimo Sirainen /* Preferred format: */
1d4f710106fb498750456724628da6063e012e6dTimo Sirainen {
9439bed2f07d6475febd8a247cd2f0990fb32a13Timo Sirainen .date_in = "Sun, 11 Nov 2007 09:42:43 GMT",
9439bed2f07d6475febd8a247cd2f0990fb32a13Timo Sirainen .tm = {
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen .tm_year = 107, .tm_mon = 10, .tm_mday = 11,
ab0d9eecd85f74acae18fe88529302e0776cc500Timo Sirainen .tm_hour = 9, .tm_min = 42, .tm_sec = 43 },
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Mon, 17 Aug 1992 13:06:27 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
336b825e0321b798690351d9899b1b0cb99ec462Timo Sirainen .tm_year = 92, .tm_mon = 7, .tm_mday = 17,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 13, .tm_min = 06, .tm_sec = 27 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Tue, 03 Sep 1974 04:38:08 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 74, .tm_mon = 8, .tm_mday = 3,
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen .tm_hour = 4, .tm_min = 38, .tm_sec = 8 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Wed, 07 May 1980 06:20:42 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 80, .tm_mon = 4, .tm_mday = 7,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 6, .tm_min = 20, .tm_sec = 42 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Thu, 15 Oct 1987 18:30:14 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 87, .tm_mon = 9, .tm_mday = 15,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 18, .tm_min = 30, .tm_sec = 14 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Fri, 20 Dec 1996 00:20:07 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 96, .tm_mon = 11, .tm_mday = 20,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 0, .tm_min = 20, .tm_sec = 7 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Sat, 19 Jan 2036 19:52:18 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 136, .tm_mon = 0, .tm_mday = 19,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 19, .tm_min = 52, .tm_sec = 18 },
46ec792dd4ccf6c34706c4774228301fafde6aa9Timo Sirainen },{
46ec792dd4ccf6c34706c4774228301fafde6aa9Timo Sirainen .date_in = "Mon, 17 Apr 2006 14:41:45 GMT",
46ec792dd4ccf6c34706c4774228301fafde6aa9Timo Sirainen .tm = {
46ec792dd4ccf6c34706c4774228301fafde6aa9Timo Sirainen .tm_year = 106, .tm_mon = 3, .tm_mday = 17,
4c6ddf2491104f917d00e6900e833e80ea02c7b6Timo Sirainen .tm_hour = 14, .tm_min = 41, .tm_sec = 45 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Sun, 06 Mar 2011 16:18:41 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 111, .tm_mon = 2, .tm_mday = 6,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 16, .tm_min = 18, .tm_sec = 41 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Sat, 14 Jun 1975 16:09:30 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 75, .tm_mon = 5, .tm_mday = 14,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 16, .tm_min = 9, .tm_sec = 30 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Fri, 05 Feb 2027 06:53:58 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen .tm_year = 127, .tm_mon = 1, .tm_mday = 5,
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen .tm_hour = 6, .tm_min = 53, .tm_sec = 58 },
d3d769026fae5d21c2d29614d3bc4579e8d79e81Timo Sirainen },{
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen .date_in = "Mon, 09 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 118, .tm_mon = 6, .tm_mday = 9,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 2, .tm_min = 24, .tm_sec = 29 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen /* Obsolete formats: */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Wednesday, 02-Jun-82 16:06:23 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_out = "Wed, 02 Jun 1982 16:06:23 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 82, .tm_mon = 5, .tm_mday = 2,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 16, .tm_min = 6, .tm_sec = 23 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Thursday, 23-May-02 12:16:24 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_out = "Thu, 23 May 2002 12:16:24 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen .tm_year = 102, .tm_mon = 4, .tm_mday = 23,
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen .tm_hour = 12, .tm_min = 16, .tm_sec = 24 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen .date_in = "Sun Nov 6 08:49:37 1994",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_out = "Sun, 06 Nov 1994 08:49:37 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 94, .tm_mon = 10, .tm_mday = 6,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 8, .tm_min = 49, .tm_sec = 37 },
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen },{
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_in = "Mon Apr 30 02:45:01 2012",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .date_out = "Mon, 30 Apr 2012 02:45:01 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_year = 112, .tm_mon = 3, .tm_mday = 30,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen .tm_hour = 2, .tm_min = 45, .tm_sec = 01 },
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen }
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen};
ad004e44be109684521494b5af2ad1da39b8bb27Timo Sirainen
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainenstatic const unsigned int valid_date_test_count = N_ELEMENTS(valid_date_tests);
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainenstatic void test_http_date_valid(void)
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen{
d3d769026fae5d21c2d29614d3bc4579e8d79e81Timo Sirainen unsigned int i;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen for (i = 0; i < valid_date_test_count; i++) T_BEGIN {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char *date_in, *date_out, *pdate_out;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const struct tm *tm = &valid_date_tests[i].tm;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen struct tm ptm;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen bool result;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen date_in = valid_date_tests[i].date_in;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen date_out = valid_date_tests[i].date_out == NULL ?
c7fca6cbb32388556d9f6d8313486cc4e4a3c058Timo Sirainen date_in : valid_date_tests[i].date_out;
c7fca6cbb32388556d9f6d8313486cc4e4a3c058Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen test_begin(t_strdup_printf("http date valid [%d]", i));
c7fca6cbb32388556d9f6d8313486cc4e4a3c058Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen result = http_date_parse_tm
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen ((const unsigned char *)date_in, strlen(date_in), &ptm);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen test_out(t_strdup_printf("parse %s", date_in), result);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen if (result) {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen bool equal = tm->tm_year == ptm.tm_year && tm->tm_mon == ptm.tm_mon &&
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen tm->tm_mday == ptm.tm_mday && tm->tm_hour == ptm.tm_hour &&
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen tm->tm_min == ptm.tm_min && tm->tm_sec == ptm.tm_sec;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen test_out("valid timestamp", equal);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen pdate_out = http_date_create_tm(&ptm);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen test_out_reason("valid create", strcmp(date_out, pdate_out) == 0,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen pdate_out);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen }
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
a75907609d7c410c9e17beedfafbf28b4439fa8aTimo Sirainen test_end();
a75907609d7c410c9e17beedfafbf28b4439fa8aTimo Sirainen } T_END;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen}
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen/* Invalid date tests */
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenstatic const char *invalid_date_tests[] = {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mom, 09 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon; 09 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 90 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 090 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Lul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 July 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 22018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 032:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:224:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:239 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02;24:29 GMT",
05e55893a799de645fc8cd2203d6013f0e0f1b79Timo Sirainen "Mon, 09 Jul 2018 02:24;29 GMT",
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen "Mon, 09 Jul 2018 45:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:90:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:84 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:29 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:29 UTC",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:29 GM",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Mon, 09 Jul 2018 02:24:29 GMTREE",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Thu, 23-May-02 12:16:24 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Thursday; 23-May-02 12:16:24 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Thursday, 223-May-02 12:16:24 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Thursday, 23-Mays-02 12:16:24 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Thursday, 23-May-2002 12:16:24 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Thursday, 23-May-02 122:16:24 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Thursday, 23-May-02 12:164:24 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Thursday, 23-May-02 12:16:244 GMT",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Thursday, 23-May-02 12:16:24 EET",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Sunday Nov 6 08:49:37 1994",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Sun Nov 6 08:49:37 1994",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Sun November 6 08:49:37 1994",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Sun Nov 6 08:49:37 1994",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Sun Nov 16 08:49:37 1994",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Sun Nov 16 08:49:37 1994",
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen "Sun Nov 6 082:49:37 1994",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Sun Nov 6 08:492:37 1994",
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen "Sun Nov 6 08:49:137 1994",
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen "Sun Nov 6 08:49:37 19914",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen "Sun Nov 6 08:49:37 0000",
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen};
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainenstatic const unsigned int invalid_date_test_count = N_ELEMENTS(invalid_date_tests);
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainenstatic void test_http_date_invalid(void)
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen{
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen unsigned int i;
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen for (i = 0; i < invalid_date_test_count; i++) T_BEGIN {
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen const char *date_in;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen struct tm tm;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen bool result;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen date_in = invalid_date_tests[i];
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen test_begin(t_strdup_printf("http date invalid [%d]", i));
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen result = http_date_parse_tm
ec23e16ed879e289d12c6e1a5f9745dd3979004aTimo Sirainen ((const unsigned char *)date_in, strlen(date_in), &tm);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen test_out(t_strdup_printf("parse %s", date_in), !result);
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen test_end();
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen } T_END;
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen}
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainenint main(void)
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen{
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen static void (*test_functions[])(void) = {
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen test_http_date_valid,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen test_http_date_invalid,
e248fe370c4047cee921a91b48edc37944ab0526Timo Sirainen NULL
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen };
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen return test_run(test_functions);
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen}
6fdfa4d4cf14d1d7764d7faa8258f112e39c8dbeTimo Sirainen