@@ -20,10 +20,12 @@ #import "OFDate.h" #import "OFString.h" #import "OFAutoreleasePool.h" +#import "OFInvalidFormatException.h" + #import "of_strptime.h" #import "TestsAppDelegate.h" static OFString *module = @"OFDate"; @@ -55,18 +57,28 @@ 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]])