Skip to content

Commit

Permalink
Add tests for MET time zone setup
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Dec 31, 2024
1 parent 7bb34b7 commit 7072a38
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
12 changes: 9 additions & 3 deletions Tests/base/NSCalendarDate/test02.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ int main()
NSMutableArray *tmpArray;
NSMutableDictionary *myLocale;
NSCalendarDate *myBirthday;
NSCalendarDate *anotherDay;
NSCalendarDate *anotherDay;
NSTimeZone *tz;

myLocale = westernLocale();

Expand Down Expand Up @@ -72,21 +73,26 @@ int main()
[tmpArray addObject: @"PM"];
[myLocale setObject: tmpArray forKey: NSAMPMDesignation];

tz = [NSTimeZone timeZoneWithName: @"MET"];
PASS_EQUAL([tz name], @"MET", "got time zone for dates")

myBirthday = [NSCalendarDate dateWithYear: 1974
month: 11
day: 20
hour: 13
minute: 0
second: 0
timeZone: [NSTimeZone timeZoneWithName: @"MET"]];
timeZone: tz];
PASS_EQUAL([myBirthday timeZone], tz, "myBirthday has expected time zone")

anotherDay = [NSCalendarDate dateWithYear: 1974
month: 1
day: 2
hour: 3
minute: 0
second: 0
timeZone: [NSTimeZone timeZoneWithName: @"MET"]];
timeZone: tz];
PASS_EQUAL([anotherDay timeZone], tz, "anotherDay has expected time zone")

PASS([[myBirthday descriptionWithCalendarFormat: @"%%"
locale: myLocale] isEqualToString: @"%"],
Expand Down
17 changes: 10 additions & 7 deletions Tests/base/NSTimeZone/create.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,34 @@ int main()

current = [NSTimeZone defaultTimeZone];
PASS(current != nil && [current isKindOfClass: [NSTimeZone class]],
"+defaultTimeZone works");
"+defaultTimeZone works")

current = [NSTimeZone localTimeZone];
PASS(current != nil && [current isKindOfClass: [NSTimeZone class]],
"+localTimeZone works");
"+localTimeZone works")

current = [NSTimeZone systemTimeZone];
PASS(current != nil && [current isKindOfClass: [NSTimeZone class]],
"+systemTimeZone works");
"+systemTimeZone works")

current = [NSTimeZone timeZoneForSecondsFromGMT: 900];
PASS(current != nil && [current isKindOfClass: [NSTimeZone class]],
"+timeZoneForSecondsFromGMT works");
"+timeZoneForSecondsFromGMT: works")

current = [NSTimeZone timeZoneForSecondsFromGMT: 90000];
PASS(current == nil,
"+timeZoneForSecondsFromGMT fails for bad offset");
"+timeZoneForSecondsFromGMT: fails for bad offset")

current = [NSTimeZone timeZoneWithAbbreviation: @"MST"];
PASS(current != nil && [current isKindOfClass: [NSTimeZone class]],
"+timeZoneWithAbbreviation works");
"+timeZoneWithAbbreviation: works")

current = [NSTimeZone timeZoneWithName: @"GB"];
PASS(current != nil && [current isKindOfClass: [NSTimeZone class]],
"+timeZoneWithName works");
"+timeZoneWithName: works")

current = [NSTimeZone timeZoneWithName: @"MET"];
PASS_EQUAL([current name], @"MET", "+timeZoneWithName: preserved name")

[arp release]; arp = nil;
return 0;
Expand Down

0 comments on commit 7072a38

Please sign in to comment.