mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Tweak unsupported
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32299 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ff4fa6aa4a
commit
4e4889ab7d
7 changed files with 101 additions and 75 deletions
|
@ -1,10 +1,18 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import <Foundation/NSCalendar.h>
|
||||
#import <Foundation/NSDate.h>
|
||||
#import <Foundation/NSDateFormatter.h>
|
||||
#import <Foundation/NSLocale.h>
|
||||
#import <Foundation/NSTimeZone.h>
|
||||
#import "Testing.h"
|
||||
#import "ObjectTesting.h"
|
||||
|
||||
#if defined(GS_USE_ICU)
|
||||
#define NSLOCALE_SUPPORTED GS_USE_ICU
|
||||
#else
|
||||
#define NSLOCALE_SUPPORTED 1 /* Assume Apple support */
|
||||
#endif
|
||||
|
||||
int main(void)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSDateFormatter *inFmt;
|
||||
NSDateFormatter *outFmt;
|
||||
NSDate *date;
|
||||
|
@ -14,56 +22,59 @@ int main(void)
|
|||
unsigned int components;
|
||||
NSInteger year;
|
||||
|
||||
[NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
|
||||
START_SET(NSLOCALE_SUPPORTED)
|
||||
|
||||
[NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
|
||||
|
||||
inFmt = [[NSDateFormatter alloc] init];
|
||||
[inFmt setDateFormat: @"yyyy-MM-dd 'at' HH:mm"];
|
||||
date = [inFmt dateFromString: @"2011-01-27 at 17:36"];
|
||||
outFmt = [[NSDateFormatter alloc] init];
|
||||
[outFmt setLocale: [[NSLocale alloc] initWithLocaleIdentifier: @"pt_BR"]];
|
||||
[outFmt setDateFormat: @"HH:mm 'on' EEEE MMMM d"];
|
||||
str = [outFmt stringFromDate: date];
|
||||
PASS_EQUAL(str, @"17:36 on quinta-feira janeiro 27",
|
||||
"Output has the same format as Cocoa.")
|
||||
RELEASE(outFmt);
|
||||
RELEASE(inFmt);
|
||||
|
||||
locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"];
|
||||
inFmt = [NSDateFormatter new];
|
||||
[inFmt setDateStyle: NSDateFormatterShortStyle];
|
||||
[inFmt setTimeStyle: NSDateFormatterNoStyle];
|
||||
[inFmt setLocale: locale];
|
||||
[inFmt setTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
|
||||
date = [inFmt dateFromString: @"15/06/1982"];
|
||||
PASS_EQUAL([date description], @"1982-06-15 00:00:00 +0000",
|
||||
"GMT time zone is correctly accounted for.");
|
||||
[inFmt setTimeZone: [NSTimeZone timeZoneWithName: @"EST"]];
|
||||
date = [inFmt dateFromString: @"15/06/1982"];
|
||||
PASS_EQUAL([date description], @"1982-06-15 05:00:00 +0000",
|
||||
"EST time zone is correctly accounted for.");
|
||||
RELEASE(inFmt);
|
||||
|
||||
cal = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
|
||||
[cal setTimeZone: [NSTimeZone timeZoneWithName: @"CST"]];
|
||||
[cal setLocale: locale];
|
||||
components = NSYearCalendarUnit;
|
||||
year = [[cal components: components fromDate: date] year];
|
||||
inFmt = [NSDateFormatter new];
|
||||
[inFmt setLocale: locale];
|
||||
[inFmt setDateStyle: NSDateFormatterLongStyle];
|
||||
[inFmt setTimeStyle: NSDateFormatterNoStyle];
|
||||
str = [inFmt stringFromDate: date];
|
||||
PASS (year == 1982, "Year is 1982");
|
||||
PASS_EQUAL(str, @"15 June 1982", "Date is formatted correctly.");
|
||||
RELEASE(cal);
|
||||
RELEASE(inFmt);
|
||||
|
||||
str = [NSDateFormatter dateFormatFromTemplate: @"MMMdd"
|
||||
options: 0 locale: locale];
|
||||
PASS_EQUAL(str, @"dd MMM", "Convert date format as Cocoa.");
|
||||
RELEASE(locale);
|
||||
|
||||
inFmt = [[NSDateFormatter alloc] init];
|
||||
[inFmt setDateFormat: @"yyyy-MM-dd 'at' HH:mm"];
|
||||
date = [inFmt dateFromString: @"2011-01-27 at 17:36"];
|
||||
outFmt = [[NSDateFormatter alloc] init];
|
||||
[outFmt setLocale: [[NSLocale alloc] initWithLocaleIdentifier: @"pt_BR"]];
|
||||
[outFmt setDateFormat: @"HH:mm 'on' EEEE MMMM d"];
|
||||
str = [outFmt stringFromDate: date];
|
||||
PASS_EQUAL(str, @"17:36 on quinta-feira janeiro 27",
|
||||
"Output has the same format as Cocoa.");
|
||||
RELEASE(outFmt);
|
||||
RELEASE(inFmt);
|
||||
|
||||
locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"];
|
||||
inFmt = [NSDateFormatter new];
|
||||
[inFmt setDateStyle: NSDateFormatterShortStyle];
|
||||
[inFmt setTimeStyle: NSDateFormatterNoStyle];
|
||||
[inFmt setLocale: locale];
|
||||
[inFmt setTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
|
||||
date = [inFmt dateFromString: @"15/06/1982"];
|
||||
PASS_EQUAL([date description], @"1982-06-15 00:00:00 +0000",
|
||||
"GMT time zone is correctly accounted for.");
|
||||
[inFmt setTimeZone: [NSTimeZone timeZoneWithName: @"EST"]];
|
||||
date = [inFmt dateFromString: @"15/06/1982"];
|
||||
PASS_EQUAL([date description], @"1982-06-15 05:00:00 +0000",
|
||||
"EST time zone is correctly accounted for.");
|
||||
RELEASE(inFmt);
|
||||
|
||||
cal = [[NSCalendar alloc] initWithCalendarIdentifier: NSGregorianCalendar];
|
||||
[cal setTimeZone: [NSTimeZone timeZoneWithName: @"CST"]];
|
||||
[cal setLocale: locale];
|
||||
components = NSYearCalendarUnit;
|
||||
year = [[cal components: components fromDate: date] year];
|
||||
inFmt = [NSDateFormatter new];
|
||||
[inFmt setLocale: locale];
|
||||
[inFmt setDateStyle: NSDateFormatterLongStyle];
|
||||
[inFmt setTimeStyle: NSDateFormatterNoStyle];
|
||||
str = [inFmt stringFromDate: date];
|
||||
PASS (year == 1982, "Year is 1982");
|
||||
PASS_EQUAL(str, @"15 June 1982", "Date is formatted correctly.");
|
||||
RELEASE(cal);
|
||||
RELEASE(inFmt);
|
||||
|
||||
str = [NSDateFormatter dateFormatFromTemplate: @"MMMdd"
|
||||
options: 0 locale: locale];
|
||||
PASS_EQUAL(str, @"dd MMM", "Convert date format as Cocoa.");
|
||||
RELEASE(locale);
|
||||
|
||||
RELEASE(pool);
|
||||
END_SET("NSDateFormatter not supported\nThe ICU library was not provided when GNUstep-base was configured/built.")
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,6 @@ int main()
|
|||
test_NSCopying(@"NSLocale", @"NSLocale",
|
||||
[NSArray arrayWithObject: testObj], NO, NO);
|
||||
|
||||
END_SET("NSLocale basic")
|
||||
END_SET("NSLocale not supported.\nThe ICU library was not provided when GNUstep-base was configured/built.")
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ int main(void)
|
|||
PASS (locale != nil, "+currentLocale return non-nil");
|
||||
TEST_FOR_CLASS(@"NSLocale", locale, "+currentLocale return a NSLocale");
|
||||
|
||||
END_SET("NSLocale create")
|
||||
END_SET("NSLocale not supported.\nThe ICU library was not provided when GNUstep-base was configured/built.")
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ int main(void)
|
|||
@"americanenglish",
|
||||
"Canonical language identifier for 'AmericanEnglish is americanenglish");
|
||||
|
||||
END_SET("NSLocale general");
|
||||
END_SET("NSLocale not supported.\nThe ICU library was not provided when GNUstep-base was configured/built.")
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ int main()
|
|||
|
||||
PASS_EQUAL(str, @"-1235", "format string of length 1")
|
||||
|
||||
END_SET("ICU library not available when base was built")
|
||||
END_SET("10.4 behaviors not supported\nThe ICU library was not provided when GNUstep-base was configured/built.")
|
||||
|
||||
END_SET("NSNumberFormatter 10.4")
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ int main()
|
|||
PASS(byteCount>0, "read www.google.com https");
|
||||
[defaultInput setDelegate: nil];
|
||||
[defaultOutput setDelegate: nil];
|
||||
END_SET("NSStream SSL support")
|
||||
END_SET("NSString SSL functions not supported\nThe GNU TLS library was not provided when GNUstep-base was configured/built.")
|
||||
|
||||
[arp release];
|
||||
return 0;
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#import "ObjectTesting.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if defined(GS_USE_ICU)
|
||||
#define NSLOCALE_SUPPORTED GS_USE_ICU
|
||||
#else
|
||||
#define NSLOCALE_SUPPORTED 1 /* Assume Apple support */
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
|
@ -44,34 +50,42 @@ int main()
|
|||
&& [current isDaylightSavingTime] == NO,
|
||||
"can set default time zone");
|
||||
|
||||
START_SET(NSLOCALE_SUPPORTED)
|
||||
|
||||
current = [NSTimeZone timeZoneWithName: @"America/Sao_Paulo"];
|
||||
locale = [[NSLocale alloc] initWithLocaleIdentifier: @"en_GB"];
|
||||
str = [current localizedName: NSTimeZoneNameStyleStandard locale: locale];
|
||||
PASS_EQUAL (str, @"Brasilia Time",
|
||||
"Correctly localizes standard time zone name");
|
||||
str = [current localizedName: NSTimeZoneNameStyleShortStandard
|
||||
locale: locale];
|
||||
PASS_EQUAL (str, @"GMT-03:00", "Correctly localizes short time zone name");
|
||||
str = [current localizedName: NSTimeZoneNameStyleDaylightSaving
|
||||
locale: locale];
|
||||
PASS_EQUAL (str, @"Brasilia Summer Time",
|
||||
"Correctly localizes DST time zone name");
|
||||
str = [current localizedName: NSTimeZoneNameStyleShortDaylightSaving
|
||||
locale: locale];
|
||||
PASS_EQUAL (str, @"GMT-02:00",
|
||||
"Correctly localizes short DST time zone name");
|
||||
PASS_EQUAL(
|
||||
[current localizedName: NSTimeZoneNameStyleStandard locale: locale],
|
||||
@"Brasilia Time",
|
||||
"Correctly localizes standard time zone name")
|
||||
PASS_EQUAL(
|
||||
[current localizedName: NSTimeZoneNameStyleShortStandard locale: locale],
|
||||
@"GMT-03:00",
|
||||
"Correctly localizes short time zone name")
|
||||
PASS_EQUAL(
|
||||
[current localizedName: NSTimeZoneNameStyleDaylightSaving locale: locale],
|
||||
@"Brasilia Summer Time",
|
||||
"Correctly localizes DST time zone name")
|
||||
PASS_EQUAL(
|
||||
[current localizedName: NSTimeZoneNameStyleShortDaylightSaving
|
||||
locale: locale],
|
||||
@"GMT-02:00",
|
||||
"Correctly localizes short DST time zone name")
|
||||
RELEASE(locale);
|
||||
|
||||
date = [NSDate dateWithTimeIntervalSince1970: 1.0];
|
||||
PASS ([current daylightSavingTimeOffsetForDate: date] == 0.0,
|
||||
"Returns correct Daylight Saving offset.");
|
||||
"Returns correct Daylight Saving offset.")
|
||||
date = [NSDate dateWithTimeIntervalSince1970: 1297308214.0];
|
||||
PASS ([current daylightSavingTimeOffsetForDate: date] == 3600.0,
|
||||
"Returns correct Daylight Saving offset.");
|
||||
"Returns correct Daylight Saving offset.")
|
||||
date = [NSDate date];
|
||||
PASS ([current daylightSavingTimeOffset] == [current daylightSavingTimeOffsetForDate: date],
|
||||
"Returns correct Daylight Saving offset.");
|
||||
PASS ([current daylightSavingTimeOffset]
|
||||
== [current daylightSavingTimeOffsetForDate: date],
|
||||
"Returns correct Daylight Saving offset.")
|
||||
|
||||
END_SET("NSLocale features not supported\nThe ICU library was not provided when GNUstep-base was configured/built.")
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue