aboutsummaryrefslogtreecommitdiff
path: root/Foundation
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-11-29 18:30:22 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2010-11-29 18:30:22 +0000
commitbc792e3a15288685a7859aca8d49bba891852bd3 (patch)
treea5bc5a42b377abd499552edd0d8ceca114fb003b /Foundation
parentcea8cb91ba371d7f02c26c4cd03267bee018ad62 (diff)
[Author: dmaclach]
Fixes up build problem on gcc 4.0 release with Xcode 3.2.5 where it doesn't deal with "interesting" ascii in @"" constants very well. DELTA=35 (29 added, 0 deleted, 6 changed) R=thomasvl
Diffstat (limited to 'Foundation')
-rw-r--r--Foundation/GTMFourCharCodeTest.m41
1 files changed, 35 insertions, 6 deletions
diff --git a/Foundation/GTMFourCharCodeTest.m b/Foundation/GTMFourCharCodeTest.m
index ac09ee0..2197f35 100644
--- a/Foundation/GTMFourCharCodeTest.m
+++ b/Foundation/GTMFourCharCodeTest.m
@@ -19,12 +19,41 @@
#import "GTMSenTestCase.h"
#import "GTMFourCharCode.h"
-@interface GTMFourCharCodeTest : GTMTestCase
+@interface GTMFourCharCodeTest : GTMTestCase {
+ @private
+ NSString *lowAsciiString_;
+ NSString *highMacOSRomanString_;
+}
+
@end
@implementation GTMFourCharCodeTest
-const FourCharCode kGTMHighMacOSRomanCode = 0xA5A8A9AA; // '•®©™'
+static const FourCharCode kGTMHighMacOSRomanCode = 0xA5A8A9AA; // '•®©™'
+
+- (void)setUp {
+ // There appears to be a bug in the gcc 4.0 that is included with Xcode
+ // 3.2.5 where in release mode it doesn't like some string constants
+ // that include high or low ascii using the @"blah" string style.
+ // So we build them by hand.
+ char string[] = { 0, 0, 0, 1 };
+ lowAsciiString_ = [[NSString alloc] initWithBytes:string
+ length:sizeof(string)
+ encoding:NSASCIIStringEncoding];
+
+ // Must make sure our bytes are in the right order for building strings with,
+ // otherwise the string comes out in the wrong order on low-endian systems.
+ FourCharCode orderedString = htonl(kGTMHighMacOSRomanCode);
+ highMacOSRomanString_
+ = [[NSString alloc] initWithBytes:&orderedString
+ length:sizeof(orderedString)
+ encoding:NSMacOSRomanStringEncoding];
+}
+
+- (void)tearDown {
+ [lowAsciiString_ release];
+ [highMacOSRomanString_ release];
+}
- (void)testFourCharCode {
GTMFourCharCode *fcc = [GTMFourCharCode fourCharCodeWithString:@"APPL"];
@@ -61,7 +90,7 @@ const FourCharCode kGTMHighMacOSRomanCode = 0xA5A8A9AA; // '•®©™'
fcc = [GTMFourCharCode fourCharCodeWithFourCharCode:1];
STAssertNotNil(fcc, nil);
- STAssertEqualObjects([fcc stringValue], @"\0\0\0\1", nil);
+ STAssertTrue([[fcc stringValue] isEqualToString:lowAsciiString_], nil);
STAssertEqualObjects([fcc numberValue],
[NSNumber numberWithUnsignedInt:1], nil);
STAssertEquals([fcc fourCharCode], (FourCharCode)1, nil);
@@ -71,7 +100,7 @@ const FourCharCode kGTMHighMacOSRomanCode = 0xA5A8A9AA; // '•®©™'
fcc2 = [GTMFourCharCode fourCharCodeWithFourCharCode:kGTMHighMacOSRomanCode];
STAssertNotNil(fcc2, nil);
- STAssertEqualObjects([fcc2 stringValue], @"•®©™", nil);
+ STAssertEqualObjects([fcc2 stringValue], highMacOSRomanString_, nil);
STAssertEqualObjects([fcc2 numberValue],
[NSNumber numberWithUnsignedInt:kGTMHighMacOSRomanCode],
nil);
@@ -83,9 +112,9 @@ const FourCharCode kGTMHighMacOSRomanCode = 0xA5A8A9AA; // '•®©™'
STAssertEqualObjects([GTMFourCharCode stringWithFourCharCode:'APPL'],
@"APPL", nil);
STAssertEqualObjects([GTMFourCharCode stringWithFourCharCode:1],
- @"\0\0\0\1", nil);
+ lowAsciiString_, nil);
STAssertEqualObjects([GTMFourCharCode stringWithFourCharCode:kGTMHighMacOSRomanCode],
- @"•®©™", nil);
+ highMacOSRomanString_, nil);
}
@end