Use UTF8String rather than cString

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40393 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2017-03-17 09:45:02 +00:00
parent 343ceb58a8
commit cc27fb0cb5
6 changed files with 92 additions and 92 deletions

View file

@ -33,7 +33,7 @@ int main()
} }
NS_HANDLER NS_HANDLER
PASS(0, "NSZoneFree() calloc'd buffer %s", PASS(0, "NSZoneFree() calloc'd buffer %s",
[[localException name] cString]); [[localException name] UTF8String]);
NS_ENDHANDLER NS_ENDHANDLER
NS_DURING NS_DURING
@ -41,7 +41,7 @@ int main()
PASS(0, "NSZoneFree() free'd buffer throws exception"); PASS(0, "NSZoneFree() free'd buffer throws exception");
NS_HANDLER NS_HANDLER
PASS(1, "NSZoneFree() free'd buffer throws exception: %s", PASS(1, "NSZoneFree() free'd buffer throws exception: %s",
[[localException name] cString]); [[localException name] UTF8String]);
NS_ENDHANDLER NS_ENDHANDLER
@ -55,7 +55,7 @@ int main()
} }
NS_HANDLER NS_HANDLER
PASS(0, "NSZoneFree() malloc'd buffer %s", PASS(0, "NSZoneFree() malloc'd buffer %s",
[[localException name] cString]); [[localException name] UTF8String]);
NS_ENDHANDLER NS_ENDHANDLER
ovp = NSZoneMalloc(aZone, 1000); ovp = NSZoneMalloc(aZone, 1000);

View file

@ -68,14 +68,14 @@ int main()
data = [@"Folded\r\n : testing\r\n" dataUsingEncoding:enc]; data = [@"Folded\r\n : testing\r\n" dataUsingEncoding:enc];
PASS([parser parse:data] && [parser isInHeaders], "Folded header is ok"); PASS([parser parse:data] && [parser isInHeaders], "Folded header is ok");
PASS([@"<hello>" isEqual: [doc contentID]],"Parsed partial header as expected %s",[[doc contentID] cString]); PASS([@"<hello>" isEqual: [doc contentID]],"Parsed partial header as expected %s",[[doc contentID] UTF8String]);
PASS([doc headerNamed: @"Folded"] == nil,"Folded header not complete until next starts"); PASS([doc headerNamed: @"Folded"] == nil,"Folded header not complete until next starts");
data = [@"\r" dataUsingEncoding:enc]; data = [@"\r" dataUsingEncoding:enc];
PASS([parser parse:data] && [parser isInHeaders], "partial end-of-line is ok"); PASS([parser parse:data] && [parser isInHeaders], "partial end-of-line is ok");
PASS([[[doc headerNamed:@"Folded"] value] isEqual: @"testing"],"Parsed folded header as expected %s",[[[doc headerNamed:@"Folded"] value] cString]); PASS([[[doc headerNamed:@"Folded"] value] isEqual: @"testing"],"Parsed folded header as expected %s",[[[doc headerNamed:@"Folded"] value] UTF8String]);
data = [@"\n" dataUsingEncoding:enc]; data = [@"\n" dataUsingEncoding:enc];
PASS([parser parse:data] && ![parser isInHeaders], "completing end-of-line is ok"); PASS([parser parse:data] && ![parser isInHeaders], "completing end-of-line is ok");

View file

@ -110,26 +110,26 @@ int main()
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date1 testDateValues: 1999 : 12 : 31 : 23 : 59 : 59], PASS([date1 testDateValues: 1999 : 12 : 31 : 23 : 59 : 59],
"date check with %s", [[date1 description] cString]); "date check with %s", [[date1 description] UTF8String]);
date2 = [date1 dateByAddingYears: 0 date2 = [date1 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2000 : 01 : 01 : 00 : 00 : 00], PASS([date2 testDateValues: 2000 : 01 : 01 : 00 : 00 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2000 : 01 : 01 : 00 : 00 : 01], PASS([date2 testDateValues: 2000 : 01 : 01 : 00 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2000 : 01 : 01 : 01 : 00 : 01], PASS([date2 testDateValues: 2000 : 01 : 01 : 01 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -2 minutes: 0 seconds: 0]; months: 0 days: 0 hours: -2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 1999 : 12 : 31 : 23 : 00 : 01], PASS([date2 testDateValues: 1999 : 12 : 31 : 23 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
/* Y2K is a leap year checks */ /* Y2K is a leap year checks */
date2 = [NSCalendarDate dateWithString: @"2000-2-28 23:59:59" date2 = [NSCalendarDate dateWithString: @"2000-2-28 23:59:59"
@ -137,73 +137,73 @@ int main()
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2000 : 02 : 28 : 23 : 59 : 59], PASS([date2 testDateValues: 2000 : 02 : 28 : 23 : 59 : 59],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2000 : 02 : 29 : 00 : 00 : 00], PASS([date2 testDateValues: 2000 : 02 : 29 : 00 : 00 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2000 : 02 : 29 : 00 : 00 : 01], PASS([date2 testDateValues: 2000 : 02 : 29 : 00 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2000 : 02 : 29 : 01 : 00 : 01], PASS([date2 testDateValues: 2000 : 02 : 29 : 01 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -2 minutes: 0 seconds: 0]; months: 0 days: 0 hours: -2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2000 : 02 : 28 : 23 : 00 : 01], PASS([date2 testDateValues: 2000 : 02 : 28 : 23 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 5 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 5 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2000 : 02 : 29 : 04 : 00 : 01], PASS([date2 testDateValues: 2000 : 02 : 29 : 04 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 1 date2 = [date2 dateByAddingYears: 1
months: 0 days: 0 hours: 0 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2001 : 03 : 01 : 04 : 00 : 01], PASS([date2 testDateValues: 2001 : 03 : 01 : 04 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: -1 hours: 0 minutes: 0 seconds: 0]; months: 0 days: -1 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2001 : 02 : 28 : 04 : 00 : 01], PASS([date2 testDateValues: 2001 : 02 : 28 : 04 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 1 date2 = [date2 dateByAddingYears: 1
months: 0 days: 1 hours: 0 minutes: 0 seconds: 0]; months: 0 days: 1 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 01 : 04 : 00 : 01], PASS([date2 testDateValues: 2002 : 03 : 01 : 04 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
/* 2004 is a year leap check */ /* 2004 is a year leap check */
date2 = [NSCalendarDate dateWithString: @"2004-2-28 23:59:59" date2 = [NSCalendarDate dateWithString: @"2004-2-28 23:59:59"
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2004 : 02 : 28 : 23 : 59 : 59], PASS([date2 testDateValues: 2004 : 02 : 28 : 23 : 59 : 59],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2004 : 02 : 29 : 00 : 00 : 00], PASS([date2 testDateValues: 2004 : 02 : 29 : 00 : 00 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2004 : 02 : 29 : 00 : 00 : 01], PASS([date2 testDateValues: 2004 : 02 : 29 : 00 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2004 : 02 : 29 : 01 : 00 : 01], PASS([date2 testDateValues: 2004 : 02 : 29 : 01 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -2 minutes: 0 seconds: 0]; months: 0 days: 0 hours: -2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2004 : 02 : 28 : 23 : 00 : 01], PASS([date2 testDateValues: 2004 : 02 : 28 : 23 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
/* 2100 is not a leap year */ /* 2100 is not a leap year */
@ -211,25 +211,25 @@ int main()
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2100 : 02 : 28 : 23 : 59 : 59], PASS([date2 testDateValues: 2100 : 02 : 28 : 23 : 59 : 59],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2100 : 03 : 01 : 00 : 00 : 00], PASS([date2 testDateValues: 2100 : 03 : 01 : 00 : 00 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2100 : 03 : 01 : 00 : 00 : 01], PASS([date2 testDateValues: 2100 : 03 : 01 : 00 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2100 : 03 : 01 : 01 : 00 : 01], PASS([date2 testDateValues: 2100 : 03 : 01 : 01 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -2 minutes: 0 seconds: 0]; months: 0 days: 0 hours: -2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2100 : 02 : 28 : 23 : 00 : 01], PASS([date2 testDateValues: 2100 : 02 : 28 : 23 : 00 : 01],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
/* daylight savings time checks */ /* daylight savings time checks */
[NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GB"]]; [NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GB"]];
@ -238,31 +238,31 @@ int main()
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 31 : 02 : 30 : 00], PASS([date2 testDateValues: 2002 : 03 : 31 : 02 : 30 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: -1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 2 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 31 : 02 : 30 : 00], PASS([date2 testDateValues: 2002 : 03 : 31 : 02 : 30 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: -1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 03 : 31 : 00 : 30 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: -1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 03 : 30 : 23 : 30 : 00], PASS([date2 testDateValues: 2002 : 03 : 30 : 23 : 30 : 00],
"date check with %s", [[date2 description] cString]); "date check with %s", [[date2 description] UTF8String]);
/* End daylight savings checks */ /* End daylight savings checks */
/* Seconds calculation checks */ /* Seconds calculation checks */
@ -270,94 +270,94 @@ int main()
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date second calculation check with %s", [[date2 description] cString]); "date second calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: -1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: -1];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 29 : 59], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 29 : 59],
"date second calculation check with %s", [[date2 description] cString]); "date second calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 1]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 1];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date second calculation check with %s", [[date2 description] cString]); "date second calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: 2]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 2];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 02], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 02],
"date second calculation check with %s", [[date2 description] cString]); "date second calculation check with %s", [[date2 description] UTF8String]);
/* Minutes calculation checks */ /* Minutes calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date minute calculation check with %s", [[date2 description] cString]); "date minute calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: -1 seconds: 0]; months: 0 days: 0 hours: 0 minutes: -1 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 29 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 29 : 00],
"date minute calculation check with %s", [[date2 description] cString]); "date minute calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 1 seconds: 0]; months: 0 days: 0 hours: 0 minutes: 1 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date minute calculation check with %s", [[date2 description] cString]); "date minute calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 1 seconds: 0]; months: 0 days: 0 hours: 0 minutes: 1 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 31 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 31 : 00],
"date minute calculation check with %s", [[date2 description] cString]); "date minute calculation check with %s", [[date2 description] UTF8String]);
/* Hour calculation checks */ /* Hour calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date hour calculation check with %s", [[date2 description] cString]); "date hour calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: -1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: -1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 26 : 23 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 26 : 23 : 30 : 00],
"date hour calculation check with %s", [[date2 description] cString]); "date hour calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 1 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 1 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date hour calculation check with %s", [[date2 description] cString]); "date hour calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 2 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 2 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 02 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 02 : 30 : 00],
"date hour calculation check with %s", [[date2 description] cString]); "date hour calculation check with %s", [[date2 description] UTF8String]);
/* Days calculation checks */ /* Days calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date day calculation check with %s", [[date2 description] cString]); "date day calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: -1 hours: 0 minutes: 0 seconds: 0]; months: 0 days: -1 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 26 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 26 : 00 : 30 : 00],
"date day calculation check with %s", [[date2 description] cString]); "date day calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 1 hours: 0 minutes: 0 seconds: 0]; months: 0 days: 1 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date day calculation check with %s", [[date2 description] cString]); "date day calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 2 hours: 0 minutes: 0 seconds: 0]; months: 0 days: 2 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 29 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 29 : 00 : 30 : 00],
"date day calculation check with %s", [[date2 description] cString]); "date day calculation check with %s", [[date2 description] UTF8String]);
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:00:00" date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:00:00"
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 00 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 00 : 00],
"date day calculation check with %s", [[date2 description] cString]); "date day calculation check with %s", [[date2 description] UTF8String]);
date2 = [NSCalendarDate dateWithString: @"2002-10-26 24:00:00" date2 = [NSCalendarDate dateWithString: @"2002-10-26 24:00:00"
calendarFormat: val2 calendarFormat: val2
@ -370,44 +370,44 @@ int main()
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date month calculation check with %s", [[date2 description] cString]); "date month calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: -1 days: 0 hours: 0 minutes: 0 seconds: 0]; months: -1 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 9 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 9 : 27 : 00 : 30 : 00],
"date month calculation check with %s", [[date2 description] cString]); "date month calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 1 days: 0 hours: 0 minutes: 0 seconds: 0]; months: 1 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date month calculation check with %s", [[date2 description] cString]); "date month calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 2 days: 0 hours: 0 minutes: 0 seconds: 0]; months: 2 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 12 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 12 : 27 : 00 : 30 : 00],
"date month calculation check with %s", [[date2 description] cString]); "date month calculation check with %s", [[date2 description] UTF8String]);
/* Years calculation checks */ /* Years calculation checks */
date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00" date2 = [NSCalendarDate dateWithString: @"2002-10-27 00:30:00"
calendarFormat: val2 calendarFormat: val2
locale: locale]; locale: locale];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date year calculation check with %s", [[date2 description] cString]); "date year calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: -1 date2 = [date2 dateByAddingYears: -1
months: 0 days: 0 hours: 0 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2001 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2001 : 10 : 27 : 00 : 30 : 00],
"date year calculation check with %s", [[date2 description] cString]); "date year calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 1 date2 = [date2 dateByAddingYears: 1
months: 0 days: 0 hours: 0 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2002 : 10 : 27 : 00 : 30 : 00],
"date year calculation check with %s", [[date2 description] cString]); "date year calculation check with %s", [[date2 description] UTF8String]);
date2 = [date2 dateByAddingYears: 2 date2 = [date2 dateByAddingYears: 2
months: 0 days: 0 hours: 0 minutes: 0 seconds: 0]; months: 0 days: 0 hours: 0 minutes: 0 seconds: 0];
PASS([date2 testDateValues: 2004 : 10 : 27 : 00 : 30 : 00], PASS([date2 testDateValues: 2004 : 10 : 27 : 00 : 30 : 00],
"date year calculation check with %s", [[date2 description] cString]); "date year calculation check with %s", [[date2 description] UTF8String]);
[NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; [NSTimeZone setDefaultTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
@ -417,7 +417,7 @@ int main()
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 1 days: 0 hours: 2 minutes: 10 seconds: 0]; months: 1 days: 0 hours: 2 minutes: 10 seconds: 0];
PASS([date2 testDateValues: 2006 : 11 : 1 : 2 : 10 : 00], PASS([date2 testDateValues: 2006 : 11 : 1 : 2 : 10 : 00],
"date year calculation check with %s", [[date2 description] cString]); "date year calculation check with %s", [[date2 description] UTF8String]);
PASS([[date2 timeZone] isEqual: tz], PASS([[date2 timeZone] isEqual: tz],
"date year calculation preserves timezone"); "date year calculation preserves timezone");
@ -427,7 +427,7 @@ int main()
date2 = [date2 dateByAddingYears: 0 date2 = [date2 dateByAddingYears: 0
months: 0 days: 0 hours: 0 minutes: 0 seconds: -3600]; months: 0 days: 0 hours: 0 minutes: 0 seconds: -3600];
PASS([date2 testDateValues: 2016 : 1 : 6 : 00 : 00 : 00], PASS([date2 testDateValues: 2016 : 1 : 6 : 00 : 00 : 00],
"date year calculation check with %s", [[date2 description] cString]); "date year calculation check with %s", [[date2 description] UTF8String]);
[arp release]; arp = nil; [arp release]; arp = nil;
return 0; return 0;

View file

@ -13,35 +13,35 @@
/* these macros should only be used in the scope of main */ /* these macros should only be used in the scope of main */
#define TEST_INVOKE(selx) \ #define TEST_INVOKE(selx) \
{ \ { \
NS_DURING \ NS_DURING \
NSMethodSignature *sig = nil; \ NSMethodSignature *sig = nil; \
sig = [tar methodSignatureForSelector:selx]; \ sig = [tar methodSignatureForSelector:selx]; \
inv = [NSInvocation invocationWithMethodSignature:sig]; \ inv = [NSInvocation invocationWithMethodSignature:sig]; \
[inv setSelector:selx]; \ [inv setSelector:selx]; \
[inv invokeWithTarget:tar]; \ [inv invokeWithTarget:tar]; \
PASS(1,"Invoke %s",[NSStringFromSelector(selx) cString]); \ PASS(1,"Invoke %s",[NSStringFromSelector(selx) UTF8String]); \
NS_HANDLER \ NS_HANDLER \
PASS(0,"Invoke %s",[NSStringFromSelector(selx) cString]); \ PASS(0,"Invoke %s",[NSStringFromSelector(selx) UTF8String]); \
[localException raise]; \ [localException raise]; \
NS_ENDHANDLER \ NS_ENDHANDLER \
} }
#define TEST_INVOKE_ARG(selx,argp) \ #define TEST_INVOKE_ARG(selx,argp) \
{ \ { \
NS_DURING \ NS_DURING \
NSMethodSignature *sig = nil; \ NSMethodSignature *sig = nil; \
sig = [tar methodSignatureForSelector:selx]; \ sig = [tar methodSignatureForSelector:selx]; \
inv = [NSInvocation invocationWithMethodSignature:sig]; \ inv = [NSInvocation invocationWithMethodSignature:sig]; \
[inv setSelector:selx]; \ [inv setSelector:selx]; \
[inv setArgument:argp atIndex:2]; \ [inv setArgument:argp atIndex:2]; \
[inv invokeWithTarget:tar]; \ [inv invokeWithTarget:tar]; \
PASS(1,"Invoke %s",[NSStringFromSelector(selx) cString]); \ PASS(1,"Invoke %s",[NSStringFromSelector(selx) UTF8String]); \
NS_HANDLER \ NS_HANDLER \
PASS(0,"Invoke %s",[NSStringFromSelector(selx) cString]); \ PASS(0,"Invoke %s",[NSStringFromSelector(selx) UTF8String]); \
[localException raise]; \ [localException raise]; \
NS_ENDHANDLER \ NS_ENDHANDLER \
} }
int main() int main()
{ {

View file

@ -105,7 +105,7 @@ int main()
[run cancelPerformSelectorsWithTarget: str]; [run cancelPerformSelectorsWithTarget: str];
date = [NSDate dateWithTimeIntervalSinceNow: delay]; date = [NSDate dateWithTimeIntervalSinceNow: delay];
[run runUntilDate: date]; [run runUntilDate: date];
PASS([str isEqualToString: @""], "-cancelPerformSelectorsWithTarget: works %s",[str cString]); PASS([str isEqualToString: @""], "-cancelPerformSelectorsWithTarget: works %s",[str UTF8String]);
[fh closeFile]; [fh closeFile];
[fh release]; [fh release];

View file

@ -130,11 +130,11 @@ void testReadBasicType_##testName (char *pre, testType *expect, testType *toDeco
[unArch decodeValueOfObjCType:@encode(testType) at:toDecode]; \ [unArch decodeValueOfObjCType:@encode(testType) at:toDecode]; \
NS_HANDLER \ NS_HANDLER \
NSLog(@"%@ %@", [localException name], [localException reason]); \ NSLog(@"%@ %@", [localException name], [localException reason]); \
PASS(0, "can unarchive %s from %s", pre, [fileName cString]); \ PASS(0, "can unarchive %s from %s", pre, [fileName UTF8String]); \
NS_ENDHANDLER \ NS_ENDHANDLER \
str2 = [unArch decodeObject]; \ str2 = [unArch decodeObject]; \
PASS((VAL_TEST(*expect,*toDecode) && [str isEqual:str2]), \ PASS((VAL_TEST(*expect,*toDecode) && [str isEqual:str2]), \
"can unarchive %s from %s", pre, [fileName cString]); \ "can unarchive %s from %s", pre, [fileName UTF8String]); \
} \ } \
} \ } \
} }