Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright 2016 Michael Gratton <mike@vee.net>
- *
- * This software is licensed under the GNU Lesser General Public License
- * (version 2.1 or later). See the COPYING file in this distribution.
- */
- class Geary.RFC822.DateTest : Gee.TestCase {
- public DateTest() {
- base("Geary.RFC822.DateTest");
- add_test("is_valid_date", is_valid_date);
- }
- // ISO 8601 "2006-08-14T02:34:56-06:00"
- // RFC5322 -> RFC2822 -> RFC822 "Wed, 24 Oct 2009 14:31:12 EST"
- // new date (8601)
- private void test_date(string? input, string? expected, bool should_throw) {
- try {
- string val = new Geary.RFC822.Date(input).to_iso_8601();
- assert(val == expected);
- assert_true(!should_throw);
- } catch (Error e) {
- assert_true(should_throw);
- }
- }
- public void is_valid_date() {
- test_date("2016-12-13T18:09:07+01:00", "2016-12-13T18:09:07+01:00", false);
- test_date("Mon, 24 Oct 2016 14:31:12 EST", "2016-10-24T21:31:12+02:00", false);
- test_date("Mon, 24 Oct 2016 14:31:12 GMT", "2016-10-24T16:31:12+02:00", false);
- test_date("Mon, 24 Oct 2016 14:31:12 +0400", "2016-10-24T12:31:12+02:00", false);
- test_date("Thu, 21 Jan 1970 00:00:00 +0000", "1970-01-21T01:00:00+01:00", false);
- test_date("Thu, 01 Jan 1970 00:00:00 +0000", "1970-01-01T01:00:00+01:00", false);
- test_date("2002-10-02T08:00:00-05:00", null, true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement