diff options
author | Dan Winship <danw@src.gnome.org> | 2005-06-14 16:40:23 +0000 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2005-06-14 16:40:23 +0000 |
commit | 0447e6791dfb19c2fae0daaba4c60abfac590180 (patch) | |
tree | 167b21821e37f51b302b768b29146b9911012e4d /tests/date.c | |
parent | 5069f32c25a4a1ef85b698d9cbd283418c8a8de7 (diff) | |
download | libsoup-0447e6791dfb19c2fae0daaba4c60abfac590180.tar.gz libsoup-0447e6791dfb19c2fae0daaba4c60abfac590180.tar.bz2 libsoup-0447e6791dfb19c2fae0daaba4c60abfac590180.zip |
check for gmtime_r
* configure.in: check for gmtime_r
* libsoup/soup-date.c: date/time-manipulation functions
* libsoup/soup-xmlrpc-message.c:
* libsoup/soup-xmlrpc-response.c: XMLRPC message classes, from
Mariano Suarez-Alvarez, Fernando Herrera, and Jeff Bailey.
[#300227]
* tests/date.c: soup-date test code
* tests/getbug.c: XMLRPC test code. (Should be switched to use
bugzilla.gnome.org once bgo supports XMLRPC.)
* TODO: XMLRPC is implemented now (but shares the problem with
SOAP that the API is not very good).
Diffstat (limited to 'tests/date.c')
-rw-r--r-- | tests/date.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/date.c b/tests/date.c new file mode 100644 index 00000000..c8054526 --- /dev/null +++ b/tests/date.c @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2005 Novell, Inc. + */ + +#include <stdio.h> +#include <string.h> + +#include <libsoup/soup-date.h> + +static int errors = 0; + +#define RFC1123_DATE "Sun, 06 Nov 1994 08:49:37 GMT" +#define RFC850_DATE "Sunday, 06-Nov-94 08:49:37 GMT" +#define ASCTIME_DATE "Sun Nov 6 08:49:37 1994" +#define ISO8601_DATE "1994-11-06T08:49:37" + +#define EXPECTED 784111777 + +static void +check (const char *test, const char *date, time_t got) +{ + if (got == EXPECTED) + return; + + fprintf (stderr, "%s date parsing failed for '%s'.\n", test, date); + fprintf (stderr, " expected: %lu, got: %lu\n\n", + (unsigned long)EXPECTED, (unsigned long)got); + errors++; +} + +int +main (int argc, char **argv) +{ + char *date; + + check ("RFC1123", RFC1123_DATE, soup_date_parse (RFC1123_DATE)); + check ("RFC850", RFC850_DATE, soup_date_parse (RFC850_DATE)); + check ("asctime", ASCTIME_DATE, soup_date_parse (ASCTIME_DATE)); + check ("iso8610", ISO8601_DATE, soup_date_iso8601_parse (ISO8601_DATE)); + + date = soup_date_generate (EXPECTED); + if (strcmp (date, RFC1123_DATE) != 0) { + fprintf (stderr, "date generation failed.\n"); + fprintf (stderr, " expected: %s\n got: %s\n\n", + RFC1123_DATE, date); + errors++; + } + + if (errors == 0) + printf ("OK\n"); + else + fprintf (stderr, "%d errors\n", errors); + return errors; +} |