Differences From Artifact [ab5193ad47]:
- File
tests/OFDateTests.m
— part of check-in
[e4439b7ef8]
at
2016-09-11 22:03:20
on branch trunk
— OFDate: Add support for parsing time zones
This adds %z for parsing time zones. Additionally, this also adds %a and
%b. (user: js, size: 3036) [annotate] [blame] [check-ins using]
To Artifact [d9a4b150fe]:
- File tests/OFDateTests.m — part of check-in [804f222e18] at 2016-09-11 22:23:45 on branch trunk — OFDate: Throw on trailing garbage (user: js, size: 3513) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <time.h> #import "OFDate.h" #import "OFString.h" #import "OFAutoreleasePool.h" #import "of_strptime.h" #import "TestsAppDelegate.h" static OFString *module = @"OFDate"; @implementation TestsAppDelegate (OFDateTests) | > > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <time.h> #import "OFDate.h" #import "OFString.h" #import "OFAutoreleasePool.h" #import "OFInvalidFormatException.h" #import "of_strptime.h" #import "TestsAppDelegate.h" static OFString *module = @"OFDate"; @implementation TestsAppDelegate (OFDateTests) |
︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | [[d2 description] isEqual: @"1970-01-02T01:00:05Z"]) TEST(@"+[dateWithDateString:format:]", [[[OFDate dateWithDateString: @"2000-06-20T12:34:56+0200" format: @"%Y-%m-%dT%H:%M:%S%z"] description] isEqual: @"2000-06-20T10:34:56Z"]); /* * We can only test local dates that specify a time zone, as the local * time zone differs between systems. */ TEST(@"+[dateWithLocalDateString:format:]", [[[OFDate dateWithLocalDateString: @"2000-06-20T12:34:56-0200" format: @"%Y-%m-%dT%H:%M:%S%z"] description] isEqual: @"2000-06-20T14:34:56Z"]); TEST(@"-[isEqual:]", [d1 isEqual: [OFDate dateWithTimeIntervalSince1970: 0]] && ![d1 isEqual: [OFDate dateWithTimeIntervalSince1970: 0.0000001]]) TEST(@"-[compare:]", [d1 compare: d2] == OF_ORDERED_ASCENDING) | > > > > > > > > > > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | [[d2 description] isEqual: @"1970-01-02T01:00:05Z"]) TEST(@"+[dateWithDateString:format:]", [[[OFDate dateWithDateString: @"2000-06-20T12:34:56+0200" format: @"%Y-%m-%dT%H:%M:%S%z"] description] isEqual: @"2000-06-20T10:34:56Z"]); EXPECT_EXCEPTION(@"Detection of unparsed in " @"+[dateWithDateString:format:]", OFInvalidFormatException, [OFDate dateWithDateString: @"2000-06-20T12:34:56+0200x" format: @"%Y-%m-%dT%H:%M:%S%z"]) /* * We can only test local dates that specify a time zone, as the local * time zone differs between systems. */ TEST(@"+[dateWithLocalDateString:format:]", [[[OFDate dateWithLocalDateString: @"2000-06-20T12:34:56-0200" format: @"%Y-%m-%dT%H:%M:%S%z"] description] isEqual: @"2000-06-20T14:34:56Z"]); EXPECT_EXCEPTION(@"Detection of unparsed in " @"+[dateWithLocalDateString:format:]", OFInvalidFormatException, [OFDate dateWithLocalDateString: @"2000-06-20T12:34:56+0200x" format: @"%Y-%m-%dT%H:%M:%S%z"]) TEST(@"-[isEqual:]", [d1 isEqual: [OFDate dateWithTimeIntervalSince1970: 0]] && ![d1 isEqual: [OFDate dateWithTimeIntervalSince1970: 0.0000001]]) TEST(@"-[compare:]", [d1 compare: d2] == OF_ORDERED_ASCENDING) |
︙ | ︙ |