/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "test-common.h"
#include "http-date.h"
#include <time.h>
struct http_date_test {
const char *date_in;
const char *date_out;
};
/* Valid date tests */
/* Preferred format: */
{
.date_in = "Sun, 11 Nov 2007 09:42:43 GMT",
.tm = {
},{
.date_in = "Mon, 17 Aug 1992 13:06:27 GMT",
.tm = {
},{
.date_in = "Tue, 03 Sep 1974 04:38:08 GMT",
.tm = {
},{
.date_in = "Wed, 07 May 1980 06:20:42 GMT",
.tm = {
},{
.date_in = "Thu, 15 Oct 1987 18:30:14 GMT",
.tm = {
},{
.date_in = "Fri, 20 Dec 1996 00:20:07 GMT",
.tm = {
},{
.date_in = "Sat, 19 Jan 2036 19:52:18 GMT",
.tm = {
},{
.date_in = "Mon, 17 Apr 2006 14:41:45 GMT",
.tm = {
},{
.date_in = "Sun, 06 Mar 2011 16:18:41 GMT",
.tm = {
},{
.date_in = "Sat, 14 Jun 1975 16:09:30 GMT",
.tm = {
},{
.date_in = "Fri, 05 Feb 2027 06:53:58 GMT",
.tm = {
},{
.date_in = "Mon, 09 Jul 2018 02:24:29 GMT",
.tm = {
/* Obsolete formats: */
},{
.date_in = "Wednesday, 02-Jun-82 16:06:23 GMT",
.date_out = "Wed, 02 Jun 1982 16:06:23 GMT",
.tm = {
},{
.date_in = "Thursday, 23-May-02 12:16:24 GMT",
.date_out = "Thu, 23 May 2002 12:16:24 GMT",
.tm = {
},{
.date_in = "Sun Nov 6 08:49:37 1994",
.date_out = "Sun, 06 Nov 1994 08:49:37 GMT",
.tm = {
},{
.date_in = "Mon Apr 30 02:45:01 2012",
.date_out = "Mon, 30 Apr 2012 02:45:01 GMT",
.tm = {
}
};
static void test_http_date_valid(void)
{
unsigned int i;
for (i = 0; i < valid_date_test_count; i++) T_BEGIN {
bool result;
if (result) {
}
test_end();
} T_END;
}
/* Invalid date tests */
static const char *invalid_date_tests[] = {
"Mom, 09 Jul 2018 02:24:29 GMT",
"Mon; 09 Jul 2018 02:24:29 GMT",
"Mon, 09 Jul 2018 02:24:29 GMT",
"Mon, 90 Jul 2018 02:24:29 GMT",
"Mon, 090 Jul 2018 02:24:29 GMT",
"Mon, 09 Jul 2018 02:24:29 GMT",
"Mon, 09 Lul 2018 02:24:29 GMT",
"Mon, 09 July 2018 02:24:29 GMT",
"Mon, 09 Jul 2018 02:24:29 GMT",
"Mon, 09 Jul 22018 02:24:29 GMT",
"Mon, 09 Jul 2018 02:24:29 GMT",
"Mon, 09 Jul 2018 032:24:29 GMT",
"Mon, 09 Jul 2018 02:224:29 GMT",
"Mon, 09 Jul 2018 02:24:239 GMT",
"Mon, 09 Jul 2018 02;24:29 GMT",
"Mon, 09 Jul 2018 02:24;29 GMT",
"Mon, 09 Jul 2018 45:24:29 GMT",
"Mon, 09 Jul 2018 02:90:29 GMT",
"Mon, 09 Jul 2018 02:24:84 GMT",
"Mon, 09 Jul 2018 02:24:29 GMT",
"Mon, 09 Jul 2018 02:24:29 UTC",
"Mon, 09 Jul 2018 02:24:29 GM",
"Mon, 09 Jul 2018 02:24:29 GMTREE",
"Thu, 23-May-02 12:16:24 GMT",
"Thursday; 23-May-02 12:16:24 GMT",
"Thursday, 223-May-02 12:16:24 GMT",
"Thursday, 23-Mays-02 12:16:24 GMT",
"Thursday, 23-May-2002 12:16:24 GMT",
"Thursday, 23-May-02 122:16:24 GMT",
"Thursday, 23-May-02 12:164:24 GMT",
"Thursday, 23-May-02 12:16:244 GMT",
"Thursday, 23-May-02 12:16:24 EET",
"Sunday Nov 6 08:49:37 1994",
"Sun Nov 6 08:49:37 1994",
"Sun November 6 08:49:37 1994",
"Sun Nov 6 08:49:37 1994",
"Sun Nov 16 08:49:37 1994",
"Sun Nov 16 08:49:37 1994",
"Sun Nov 6 082:49:37 1994",
"Sun Nov 6 08:492:37 1994",
"Sun Nov 6 08:49:137 1994",
"Sun Nov 6 08:49:37 19914",
"Sun Nov 6 08:49:37 0000",
};
static void test_http_date_invalid(void)
{
unsigned int i;
for (i = 0; i < invalid_date_test_count; i++) T_BEGIN {
const char *date_in;
bool result;
date_in = invalid_date_tests[i];
test_end();
} T_END;
}
int main(void)
{
static void (*const test_functions[])(void) = {
};
return test_run(test_functions);
}