From 7bb8e9b9b24141f373ed70d7e6674a245c0227cf Mon Sep 17 00:00:00 2001 From: "thomasvl@gmail.com" Date: Mon, 22 Sep 2008 23:33:44 +0000 Subject: - Added GTMTestTimer.h for doing high fidelity timings. - Added leaks checking to iPhone unit test script. It can be controlled by the GTM_DISABLE_LEAKS environment variable - Added ability to control using zombies to iPhone unit test script. It can be controlled by the GTM_DISABLE_ZOMBIES environment variable - Added ability to control termination to iPhone unit test script. It can be controlled by the GTM_DISABLE_TERMINATION environment variable - Fixed several leaks found with leak checking enabled. - Added configs for different iPhone OS versions. --- iPhone/GTMABAddressBook.m | 3 +++ iPhone/GTMABAddressBookTest.m | 33 ++++++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'iPhone') diff --git a/iPhone/GTMABAddressBook.m b/iPhone/GTMABAddressBook.m index 0c54364..c06b511 100644 --- a/iPhone/GTMABAddressBook.m +++ b/iPhone/GTMABAddressBook.m @@ -189,6 +189,7 @@ typedef struct { - (id)initWithRecord:(ABRecordRef)record { if ((self = [super init])) { if ([self class] == [GTMABRecord class]) { + [self autorelease]; [self doesNotRecognizeSelector:_cmd]; } if (!record) { @@ -509,6 +510,8 @@ typedef struct { @implementation GTMABMultiValue - (id)init { + // Call super init and release so we don't leak + [[super init] autorelease]; [self doesNotRecognizeSelector:_cmd]; return nil; // COV_NF_LINE } diff --git a/iPhone/GTMABAddressBookTest.m b/iPhone/GTMABAddressBookTest.m index 3ecb796..56106a9 100644 --- a/iPhone/GTMABAddressBookTest.m +++ b/iPhone/GTMABAddressBookTest.m @@ -534,24 +534,31 @@ thirdRetainCount, @"Testing type %d, %@", type, val); + id oldVal = val; val = (id)ABMultiValueCopyValueAtIndex(ref, 0); NSUInteger fourthRetainCount = [val retainCount]; - if (type == kABIntegerPropertyType - || type == kABRealPropertyType - || type == kABDictionaryPropertyType) { - // We are verifying that yes indeed 6208390 is still broken - STAssertEquals(fourthRetainCount, - thirdRetainCount, - @"Testing type %d, %@. If you see this error it may " - @"be time to update the code to change retain behaviors" - @"with this os version", type, val); + + // kABDictionaryPropertyTypes appear to do an actual copy, so the retain + // count checking trick won't work. We only check the retain count if + // we didn't get a new version. + if (val == oldVal) { + if (type == kABIntegerPropertyType + || type == kABRealPropertyType) { + // We are verifying that yes indeed 6208390 is still broken + STAssertEquals(fourthRetainCount, + thirdRetainCount, + @"Testing type %d, %@. If you see this error it may " + @"be time to update the code to change retain behaviors" + @"with this os version", type, val); + } else { + STAssertEquals(fourthRetainCount, + thirdRetainCount + 1, + @"Testing type %d, %@", type, val); + [val release]; + } } else { - STAssertEquals(fourthRetainCount, - thirdRetainCount + 1, - @"Testing type %d, %@", type, val); [val release]; } - CFRelease(ref); } } -- cgit v1.2.3