aboutsummaryrefslogtreecommitdiff
path: root/AddressBook
diff options
context:
space:
mode:
authorGravatar dmaclach <dmaclach@google.com>2016-10-07 12:10:23 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2016-10-07 12:21:06 -0400
commit42124b3691197c3c4f52f069775fa0390a8ff942 (patch)
treeebd373d398ea64b45bdc1d196fa0a2c5f57cabfd /AddressBook
parent57eeab4193210df8ab0c81e9d3f1ee1ad3e24492 (diff)
First cut at pruning things/updating things.
Remove a bunch of code that Google stopped using/maintaining rather than trying to update it it. Some would be hard to update, some actually has system provided replacements; others are patterns that just don't seem as common now. Prune out the code related to macOS <= 10.5, start pruning some of the really old iOS support also. Get the projects mostly limping again with modern Xcodes so tests can be run. If someone ends up on this commit via history for something they still find as useful, feel free to do a pull request to bring the snippet of code back to life and update it for current SDKs.
Diffstat (limited to 'AddressBook')
-rw-r--r--AddressBook/GTMABAddressBook.m251
-rw-r--r--AddressBook/GTMABAddressBookTest.m498
2 files changed, 377 insertions, 372 deletions
diff --git a/AddressBook/GTMABAddressBook.m b/AddressBook/GTMABAddressBook.m
index d71aa91..c6916f9 100644
--- a/AddressBook/GTMABAddressBook.m
+++ b/AddressBook/GTMABAddressBook.m
@@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -25,15 +25,6 @@
#import <Cocoa/Cocoa.h>
#endif // GTM_IPHONE_SDK
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
-// Tiger does not have this functionality, so we just set them to 0
-// as they are "or'd" in. This does change the functionality slightly.
-enum {
- NSDiacriticInsensitiveSearch = 0,
- NSWidthInsensitiveSearch = 0
-};
-#endif
-
NSString *const kGTMABUnknownPropertyName = @"UNKNOWN_PROPERTY";
typedef struct {
@@ -62,11 +53,9 @@ typedef struct {
+ (id)valueEnumeratorFor:(GTMABMultiValue*)enumeree;
+ (id)labelEnumeratorFor:(GTMABMultiValue*)enumeree;
- (id)initWithEnumeree:(GTMABMultiValue*)enumeree useLabels:(BOOL)useLabels;
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
- objects:(id *)stackbuf
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
+ objects:(id *)stackbuf
count:(NSUInteger)len;
-#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
@end
@implementation GTMABAddressBook
@@ -109,7 +98,7 @@ typedef struct {
CFErrorRef cfError = NULL;
bool wasGood = ABAddressBookSave(addressBook_, &cfError);
if (!wasGood) {
- _GTMDevLog(@"Error in [%@ %@]: %@",
+ _GTMDevLog(@"Error in [%@ %@]: %@",
[self class], NSStringFromSelector(_cmd), cfError);
CFRelease(cfError);
}
@@ -135,13 +124,13 @@ typedef struct {
if (!record) return NO;
#if GTM_IPHONE_SDK
CFErrorRef cfError = NULL;
- bool wasGood = ABAddressBookAddRecord(addressBook_,
+ bool wasGood = ABAddressBookAddRecord(addressBook_,
[record recordRef], &cfError);
if (cfError) {
// COV_NF_START
- _GTMDevLog(@"Error in [%@ %@]: %@",
+ _GTMDevLog(@"Error in [%@ %@]: %@",
[self class], NSStringFromSelector(_cmd), cfError);
- CFRelease(cfError);
+ CFRelease(cfError);
// COV_NF_END
}
#else // GTM_IPHONE_SDK
@@ -156,11 +145,11 @@ typedef struct {
if (!record) return NO;
#if GTM_IPHONE_SDK
CFErrorRef cfError = NULL;
- bool wasGood = ABAddressBookRemoveRecord(addressBook_,
+ bool wasGood = ABAddressBookRemoveRecord(addressBook_,
[record recordRef], &cfError);
if (cfError) {
// COV_NF_START
- _GTMDevLog(@"Error in [%@ %@]: %@",
+ _GTMDevLog(@"Error in [%@ %@]: %@",
[self class], NSStringFromSelector(_cmd), cfError);
CFRelease(cfError);
// COV_NF_END
@@ -175,19 +164,19 @@ typedef struct {
}
#endif // GTM_IPHONE_SDK
return wasGood ? YES : NO;
-}
+}
- (NSArray *)people {
#if GTM_IPHONE_SDK
- NSArray *people
+ NSArray *people
= GTMCFAutorelease(ABAddressBookCopyArrayOfAllPeople(addressBook_));
#else // GTM_IPHONE_SDK
- NSArray *people
+ NSArray *people
= GTMCFAutorelease(ABCopyArrayOfAllPeople(addressBook_));
-#endif // GTM_IPHONE_SDK
+#endif // GTM_IPHONE_SDK
NSMutableArray *result = [NSMutableArray arrayWithCapacity:[people count]];
id person;
- GTM_FOREACH_OBJECT(person, people) {
+ for (person in people) {
[result addObject:[GTMABPerson recordWithRecord:person]];
}
return result;
@@ -195,15 +184,15 @@ typedef struct {
- (NSArray *)groups {
#if GTM_IPHONE_SDK
- NSArray *groups
+ NSArray *groups
= GTMCFAutorelease(ABAddressBookCopyArrayOfAllGroups(addressBook_));
#else // GTM_IPHONE_SDK
- NSArray *groups
+ NSArray *groups
= GTMCFAutorelease(ABCopyArrayOfAllGroups(addressBook_));
-#endif // GTM_IPHONE_SDK
+#endif // GTM_IPHONE_SDK
NSMutableArray *result = [NSMutableArray arrayWithCapacity:[groups count]];
id group;
- GTM_FOREACH_OBJECT(group, groups) {
+ for (group in groups) {
[result addObject:[GTMABGroup recordWithRecord:group]];
}
return result;
@@ -218,7 +207,7 @@ typedef struct {
#if GTM_IPHONE_SDK
ABRecordRef ref = ABAddressBookGetPersonWithRecordID(addressBook_, uniqueId);
#else // GTM_IPHONE_SDK
- ABRecordRef ref = ABCopyRecordForUniqueId(addressBook_,
+ ABRecordRef ref = ABCopyRecordForUniqueId(addressBook_,
(CFStringRef)uniqueId);
#endif // GTM_IPHONE_SDK
if (ref) {
@@ -232,7 +221,7 @@ typedef struct {
#if GTM_IPHONE_SDK
ABRecordRef ref = ABAddressBookGetGroupWithRecordID(addressBook_, uniqueId);
#else // GTM_IPHONE_SDK
- ABRecordRef ref = ABCopyRecordForUniqueId(addressBook_,
+ ABRecordRef ref = ABCopyRecordForUniqueId(addressBook_,
(CFStringRef)uniqueId);
#endif // GTM_IPHONE_SDK
if (ref) {
@@ -241,16 +230,16 @@ typedef struct {
return group;
}
-// Performs a prefix search on the composite names of people in an address book
+// Performs a prefix search on the composite names of people in an address book
// and returns an array of persons that match the search criteria.
- (NSArray *)peopleWithCompositeNameWithPrefix:(NSString *)prefix {
#if GTM_IPHONE_SDK
- NSArray *people =
+ NSArray *people =
GTMCFAutorelease(ABAddressBookCopyPeopleWithName(addressBook_,
(CFStringRef)prefix));
NSMutableArray *gtmPeople = [NSMutableArray arrayWithCapacity:[people count]];
id person;
- GTM_FOREACH_OBJECT(person, people) {
+ for (person in people) {
GTMABPerson *gtmPerson = [GTMABPerson recordWithRecord:person];
[gtmPeople addObject:gtmPerson];
}
@@ -263,10 +252,10 @@ typedef struct {
NSArray *people = [self people];
NSMutableArray *foundPeople = [NSMutableArray array];
GTMABPerson *person;
- GTM_FOREACH_OBJECT(person, people) {
+ for (person in people) {
NSString *compositeName = [person compositeName];
NSRange range = [compositeName rangeOfString:prefix
- options:(NSCaseInsensitiveSearch
+ options:(NSCaseInsensitiveSearch
| NSDiacriticInsensitiveSearch
| NSWidthInsensitiveSearch
| NSAnchoredSearch)];
@@ -278,16 +267,16 @@ typedef struct {
#endif
}
-// Performs a prefix search on the composite names of groups in an address book
+// Performs a prefix search on the composite names of groups in an address book
// and returns an array of groups that match the search criteria.
- (NSArray *)groupsWithCompositeNameWithPrefix:(NSString *)prefix {
NSArray *groups = [self groups];
NSMutableArray *foundGroups = [NSMutableArray array];
GTMABGroup *group;
- GTM_FOREACH_OBJECT(group, groups) {
+ for (group in groups) {
NSString *compositeName = [group compositeName];
NSRange range = [compositeName rangeOfString:prefix
- options:(NSCaseInsensitiveSearch
+ options:(NSCaseInsensitiveSearch
| NSDiacriticInsensitiveSearch
| NSWidthInsensitiveSearch
| NSAnchoredSearch)];
@@ -296,7 +285,7 @@ typedef struct {
}
}
return foundGroups;
-}
+}
+ (NSString *)localizedLabel:(NSString *)label {
#if GTM_IPHONE_SDK
@@ -342,7 +331,7 @@ typedef struct {
// 6203836 ABRecords hash to their address
// but it's the best we can do without knowing what properties
// are in a record, and we don't have an API for that.
- return [object respondsToSelector:@selector(recordRef)]
+ return [object respondsToSelector:@selector(recordRef)]
&& CFEqual(record_, [object recordRef]);
}
@@ -368,12 +357,12 @@ typedef struct {
- (id)valueForProperty:(GTMABPropertyID)property {
#if GTM_IPHONE_SDK
id value = GTMCFAutorelease(ABRecordCopyValue(record_, property));
-#else // GTM_IPHONE_SDK
+#else // GTM_IPHONE_SDK
id value = GTMCFAutorelease(ABRecordCopyValue(record_, (CFStringRef)property));
#endif // GTM_IPHONE_SDK
if (value) {
if ([[self class] typeOfProperty:property] & kABMultiValueMask) {
- value = [[[GTMABMultiValue alloc]
+ value = [[[GTMABMultiValue alloc]
initWithMultiValue:(ABMultiValueRef)value] autorelease];
}
}
@@ -384,7 +373,7 @@ typedef struct {
if (!value) return NO;
// We check the type here because of
// Radar 6201046 ABRecordSetValue returns true even if you pass in a bad type
- // for a value
+ // for a value
TypeClassNameMap fullTypeMap[] = {
{ kGTMABStringPropertyType, [NSString class] },
{ kGTMABIntegerPropertyType, [NSNumber class] },
@@ -414,11 +403,11 @@ typedef struct {
}
#if GTM_IPHONE_SDK
CFErrorRef cfError = nil;
- bool wasGood = ABRecordSetValue(record_, property,
+ bool wasGood = ABRecordSetValue(record_, property,
(CFTypeRef)value, &cfError);
if (cfError) {
// COV_NF_START
- _GTMDevLog(@"Error in [%@ %@]: %@",
+ _GTMDevLog(@"Error in [%@ %@]: %@",
[self class], NSStringFromSelector(_cmd), cfError);
CFRelease(cfError);
// COV_NF_END
@@ -433,13 +422,13 @@ typedef struct {
#if GTM_IPHONE_SDK
CFErrorRef cfError = nil;
// We check to see if the value is in the property because of:
- // Radar 6201005 ABRecordRemoveValue returns true for value that aren't
+ // Radar 6201005 ABRecordRemoveValue returns true for value that aren't
// in the record
id value = [self valueForProperty:property];
bool wasGood = value && ABRecordRemoveValue(record_, property, &cfError);
if (cfError) {
// COV_NF_START
- _GTMDevLog(@"Error in [%@ %@]: %@",
+ _GTMDevLog(@"Error in [%@ %@]: %@",
[self class], NSStringFromSelector(_cmd), cfError);
CFRelease(cfError);
// COV_NF_END
@@ -466,20 +455,20 @@ typedef struct {
+ (NSString *)localizedPropertyName:(GTMABPropertyID)property {
[self doesNotRecognizeSelector:_cmd];
- return nil;
+ return nil;
}
// COV_NF_END
@end
@implementation GTMABPerson
-+ (GTMABPerson *)personWithFirstName:(NSString *)first
++ (GTMABPerson *)personWithFirstName:(NSString *)first
lastName:(NSString *)last {
GTMABPerson *person = [[[self alloc] init] autorelease];
if (person) {
BOOL isGood = YES;
if (first) {
- isGood = [person setValue:first
+ isGood = [person setValue:first
forProperty:kGTMABPersonFirstNameProperty];
}
if (isGood && last) {
@@ -500,7 +489,7 @@ typedef struct {
self = [super initWithRecord:person];
if (person) {
CFRelease(person);
- }
+ }
return self;
}
@@ -514,12 +503,12 @@ typedef struct {
// We verify that the data is good because of:
// Radar 6202868 ABPersonSetImageData should validate image data
UIImage *image = [UIImage imageWithData:data];
- wasGood = image && ABPersonSetImageData([self recordRef],
+ wasGood = image && ABPersonSetImageData([self recordRef],
(CFDataRef)data, &cfError);
}
if (cfError) {
// COV_NF_START
- _GTMDevLog(@"Error in [%@ %@]: %@",
+ _GTMDevLog(@"Error in [%@ %@]: %@",
[self class], NSStringFromSelector(_cmd), cfError);
CFRelease(cfError);
// COV_NF_END
@@ -569,7 +558,7 @@ typedef struct {
} else {
NSString *firstName = [self valueForProperty:kGTMABPersonFirstNameProperty];
NSString *lastName = [self valueForProperty:kGTMABPersonLastNameProperty];
-
+
if (firstName && lastName) {
GTMABPersonCompositeNameFormat format;
if (flags & kABFirstNameFirst) {
@@ -593,7 +582,7 @@ typedef struct {
compositeName = @"";
}
}
-
+
return compositeName;
#endif // GTM_IPHONE_SDK
}
@@ -601,13 +590,13 @@ typedef struct {
- (NSString *)description {
#if GTM_IPHONE_SDK
return [NSString stringWithFormat:@"%@ %@ %@ %d",
- [self class],
+ [self class],
[self valueForProperty:kGTMABPersonFirstNameProperty],
[self valueForProperty:kGTMABPersonLastNameProperty],
- [self recordID]];
+ [self recordID]];
#else // GTM_IPHONE_SDK
return [NSString stringWithFormat:@"%@ %@ %@ %@",
- [self class],
+ [self class],
[self valueForProperty:kGTMABPersonFirstNameProperty],
[self valueForProperty:kGTMABPersonLastNameProperty],
[self recordID]];
@@ -616,7 +605,7 @@ typedef struct {
+ (NSString *)localizedPropertyName:(GTMABPropertyID)property {
#if GTM_IPHONE_SDK
- return GTMCFAutorelease(ABPersonCopyLocalizedPropertyName(property));
+ return GTMCFAutorelease(ABPersonCopyLocalizedPropertyName(property));
#else // GTM_IPHONE_SDK
return ABLocalizedPropertyOrLabel(property);
#endif // GTM_IPHONE_SDK
@@ -630,9 +619,9 @@ typedef struct {
return ABPersonGetCompositeNameFormatForRecord(NULL);
#endif // __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0
#else // GTM_IPHONE_SDK
- NSInteger nameOrdering
+ NSInteger nameOrdering
= [[ABAddressBook sharedAddressBook] defaultNameOrdering];
- return nameOrdering == kABFirstNameFirst ?
+ return nameOrdering == kABFirstNameFirst ?
kABPersonCompositeNameFormatFirstNameFirst :
kABPersonCompositeNameFormatLastNameFirst;
#endif // GTM_IPHONE_SDK
@@ -642,8 +631,8 @@ typedef struct {
#if GTM_IPHONE_SDK
return ABPersonGetTypeOfProperty(property);
#else // GTM_IPHONE_SDK
- return ABTypeOfProperty([[GTMABAddressBook addressBook] addressBookRef],
- (CFStringRef)kABPersonRecordType,
+ return ABTypeOfProperty([[GTMABAddressBook addressBook] addressBookRef],
+ (CFStringRef)kABPersonRecordType,
(CFStringRef)property);
#endif // GTM_IPHONE_SDK
}
@@ -669,41 +658,41 @@ typedef struct {
self = [super initWithRecord:group];
if (group) {
CFRelease(group);
- }
+ }
return self;
}
- (NSArray *)members {
- NSArray *people
+ NSArray *people
= GTMCFAutorelease(ABGroupCopyArrayOfAllMembers([self recordRef]));
NSMutableArray *gtmPeople = [NSMutableArray arrayWithCapacity:[people count]];
id person;
- GTM_FOREACH_OBJECT(person, people) {
+ for (person in people) {
[gtmPeople addObject:[GTMABPerson recordWithRecord:(ABRecordRef)person]];
}
return gtmPeople;
-}
+}
- (BOOL)addMember:(GTMABPerson *)person {
#if GTM_IPHONE_SDK
CFErrorRef cfError = nil;
// We check for person because of
// Radar 6202860 Passing nil person into ABGroupAddMember crashes
- bool wasGood = person && ABGroupAddMember([self recordRef],
+ bool wasGood = person && ABGroupAddMember([self recordRef],
[person recordRef], &cfError);
if (cfError) {
// COV_NF_START
- _GTMDevLog(@"Error in [%@ %@]: %@",
+ _GTMDevLog(@"Error in [%@ %@]: %@",
[self class], NSStringFromSelector(_cmd), cfError);
CFRelease(cfError);
// COV_NF_END
}
#else // GTM_IPHONE_SDK
- bool wasGood = person && ABGroupAddMember([self recordRef],
+ bool wasGood = person && ABGroupAddMember([self recordRef],
[person recordRef]);
#endif // GTM_IPHONE_SDK
return wasGood ? YES : NO;
-}
+}
- (BOOL)removeMember:(GTMABPerson *)person {
#if GTM_IPHONE_SDK
@@ -711,11 +700,11 @@ typedef struct {
// We check for person because of
// Radar 6202860 Passing nil person into ABGroupAddMember crashes
// (I know this is remove, but it crashes there too)
- bool wasGood = person && ABGroupRemoveMember([self recordRef],
+ bool wasGood = person && ABGroupRemoveMember([self recordRef],
[person recordRef], &cfError);
if (cfError) {
// COV_NF_START
- _GTMDevLog(@"Error in [%@ %@]: %@",
+ _GTMDevLog(@"Error in [%@ %@]: %@",
[self class], NSStringFromSelector(_cmd), cfError);
CFRelease(cfError);
// COV_NF_END
@@ -725,7 +714,7 @@ typedef struct {
if (wasGood) {
NSArray *array = GTMCFAutorelease(ABPersonCopyParentGroups([person recordRef]));
if ([array containsObject:[self recordRef]]) {
- wasGood = ABGroupRemoveMember([self recordRef],
+ wasGood = ABGroupRemoveMember([self recordRef],
[person recordRef]);
} else {
wasGood = NO;
@@ -733,7 +722,7 @@ typedef struct {
}
#endif // GTM_IPHONE_SDK
return wasGood ? YES : NO;
-}
+}
- (NSString *)compositeName {
#if GTM_IPHONE_SDK
@@ -747,7 +736,7 @@ typedef struct {
GTMABPropertyType type = kGTMABInvalidPropertyType;
if (property == kABGroupNameProperty) {
type = kGTMABStringPropertyType;
- }
+ }
return type;
}
@@ -755,7 +744,7 @@ typedef struct {
NSString *name = kGTMABUnknownPropertyName;
if (property == kABGroupNameProperty) {
name = NSLocalizedStringFromTable(@"Name",
- @"GTMABAddressBook",
+ @"GTMABAddressBook",
@"name property");
}
return name;
@@ -763,13 +752,13 @@ typedef struct {
- (NSString *)description {
#if GTM_IPHONE_SDK
- return [NSString stringWithFormat:@"%@ %@ %d",
- [self class],
+ return [NSString stringWithFormat:@"%@ %@ %d",
+ [self class],
[self valueForProperty:kABGroupNameProperty],
[self recordID]];
#else // GTM_IPHONE_SDK
- return [NSString stringWithFormat:@"%@ %@ %@",
- [self class],
+ return [NSString stringWithFormat:@"%@ %@ %@",
+ [self class],
[self valueForProperty:kABGroupNameProperty],
[self recordID]];
#endif // GTM_IPHONE_SDK
@@ -823,7 +812,7 @@ typedef struct {
// 6203854 ABMultiValues hash to their address
// and it appears CFEquals just calls through to hash to compare them.
BOOL isEqual = NO;
- if ([object respondsToSelector:@selector(multiValueRef)]) {
+ if ([object respondsToSelector:@selector(multiValueRef)]) {
isEqual = multiValue_ == [object multiValueRef];
if (!isEqual) {
NSUInteger count = [self count];
@@ -835,7 +824,7 @@ typedef struct {
isEqual = [label isEqual:objLabel];
if (isEqual) {
id value = [self valueAtIndex:i];
- GTMABMultiValue *multiValueObject
+ GTMABMultiValue *multiValueObject
= GTM_STATIC_CAST(GTMABMultiValue, object);
id objValue = [multiValueObject valueAtIndex:i];
isEqual = [value isEqual:objValue];
@@ -870,13 +859,13 @@ typedef struct {
if (idx < [self count]) {
value = GTMCFAutorelease(ABMultiValueCopyValueAtIndex(multiValue_, idx));
ABPropertyType type = [self propertyType];
- if (type == kGTMABIntegerPropertyType
+ if (type == kGTMABIntegerPropertyType
|| type == kGTMABRealPropertyType
|| type == kGTMABDictionaryPropertyType) {
// This is because of
// 6208390 Integer and real values don't work in ABMultiValueRefs
- // Apparently they forget to add a ref count on int, real and
- // dictionary values in ABMultiValueCopyValueAtIndex, although they do
+ // Apparently they forget to add a ref count on int, real and
+ // dictionary values in ABMultiValueCopyValueAtIndex, although they do
// remember them for all other types.
// Once they fix this, this will lead to a leak, but I figure the leak
// is better than the crash. Our unittests will test to make sure that
@@ -907,7 +896,7 @@ typedef struct {
#if GTM_IPHONE_SDK
identifier = ABMultiValueGetIdentifierAtIndex(multiValue_, idx);
#else // GTM_IPHONE_SDK
- identifier = GTMCFAutorelease(ABMultiValueCopyIdentifierAtIndex(multiValue_,
+ identifier = GTMCFAutorelease(ABMultiValueCopyIdentifierAtIndex(multiValue_,
idx));
#endif // GTM_IPHONE_SDK
}
@@ -918,7 +907,7 @@ typedef struct {
#if GTM_IPHONE_SDK
NSUInteger idx = ABMultiValueGetIndexForIdentifier(multiValue_, identifier);
#else // GTM_IPHONE_SDK
- NSUInteger idx = ABMultiValueIndexForIdentifier(multiValue_,
+ NSUInteger idx = ABMultiValueIndexForIdentifier(multiValue_,
(CFStringRef)identifier);
#endif // GTM_IPHONE_SDK
return idx == (NSUInteger)kCFNotFound ? (NSUInteger)NSNotFound : idx;
@@ -974,7 +963,7 @@ typedef struct {
self = [super initWithMultiValue:ref];
if (ref) {
CFRelease(ref);
- }
+ }
return self;
}
@@ -986,7 +975,7 @@ typedef struct {
self = [super initWithMultiValue:ref];
if (ref) {
CFRelease(ref);
- }
+ }
return self;
}
@@ -1006,11 +995,11 @@ typedef struct {
};
GTMABPropertyType type = [self propertyType] & ~kABMultiValueMask;
#if GTM_MACOS_SDK
- // Since on the desktop mutables don't have a type UNTIL they have
+ // Since on the desktop mutables don't have a type UNTIL they have
// something in them, return YES if it's empty.
if ((type == 0) && ([self count] == 0)) return YES;
#endif // GTM_MACOS_SDK
- for (size_t i = 0;
+ for (size_t i = 0;
i < sizeof(singleValueTypeMap) / sizeof(TypeClassNameMap); ++i) {
if (singleValueTypeMap[i].pType == type) {
if ([[value class] isSubclassOfClass:singleValueTypeMap[i].class]) {
@@ -1030,14 +1019,14 @@ typedef struct {
bool wasGood = label && [self checkValueType:value];
if (wasGood) {
#if GTM_IPHONE_SDK
- wasGood = ABMultiValueAddValueAndLabel(multiValue_,
- value,
- label,
+ wasGood = ABMultiValueAddValueAndLabel(multiValue_,
+ value,
+ label,
&identifier);
-#else // GTM_IPHONE_SDK
- wasGood = ABMultiValueAdd((ABMutableMultiValueRef)multiValue_,
- value,
- label,
+#else // GTM_IPHONE_SDK
+ wasGood = ABMultiValueAdd((ABMutableMultiValueRef)multiValue_,
+ value,
+ label,
(CFStringRef *)&identifier);
#endif // GTM_IPHONE_SDK
}
@@ -1049,12 +1038,12 @@ typedef struct {
return identifier;
}
-- (GTMABMultiValueIdentifier)insertValue:(id)value
- withLabel:(CFStringRef)label
+- (GTMABMultiValueIdentifier)insertValue:(id)value
+ withLabel:(CFStringRef)label
atIndex:(NSUInteger)idx {
GTMABMultiValueIdentifier identifier = kGTMABMultiValueInvalidIdentifier;
// We perform a check here to ensure that we don't get bitten by
- // Radar 6202807 ABMultiValueInsertValueAndLabelAtIndex allows you to insert
+ // Radar 6202807 ABMultiValueInsertValueAndLabelAtIndex allows you to insert
// values past end
NSUInteger count = [self count];
// We check label and value here because of
@@ -1062,16 +1051,16 @@ typedef struct {
bool wasGood = idx <= count && label && [self checkValueType:value];
if (wasGood) {
#if GTM_IPHONE_SDK
- wasGood = ABMultiValueInsertValueAndLabelAtIndex(multiValue_,
- value,
- label,
- idx,
+ wasGood = ABMultiValueInsertValueAndLabelAtIndex(multiValue_,
+ value,
+ label,
+ idx,
&identifier);
#else // GTM_IPHONE_SDK
- wasGood = ABMultiValueInsert((ABMutableMultiValueRef)multiValue_,
- value,
- label,
- idx,
+ wasGood = ABMultiValueInsert((ABMutableMultiValueRef)multiValue_,
+ value,
+ label,
+ idx,
(CFStringRef *)&identifier);
#endif // GTM_IPHONE_SDK
}
@@ -1088,7 +1077,7 @@ typedef struct {
NSUInteger count = [self count];
if (idx < count) {
#if GTM_IPHONE_SDK
- bool wasGood = ABMultiValueRemoveValueAndLabelAtIndex(multiValue_,
+ bool wasGood = ABMultiValueRemoveValueAndLabelAtIndex(multiValue_,
idx);
#else // GTM_IPHONE_SDK
bool wasGood = ABMultiValueRemove((ABMutableMultiValueRef)multiValue_,
@@ -1099,7 +1088,7 @@ typedef struct {
isGood = YES;
}
}
- return isGood;
+ return isGood;
}
- (BOOL)replaceValueAtIndex:(NSUInteger)idx withValue:(id)value {
@@ -1107,11 +1096,11 @@ typedef struct {
NSUInteger count = [self count];
if (idx < count && [self checkValueType:value]) {
#if GTM_IPHONE_SDK
- bool goodReplace = ABMultiValueReplaceValueAtIndex(multiValue_,
+ bool goodReplace = ABMultiValueReplaceValueAtIndex(multiValue_,
value, idx);
#else // GTM_IPHONE_SDK
- bool goodReplace
- = ABMultiValueReplaceValue((ABMutableMultiValueRef)multiValue_,
+ bool goodReplace
+ = ABMultiValueReplaceValue((ABMutableMultiValueRef)multiValue_,
(CFTypeRef)value, idx);
#endif // GTM_IPHONE_SDK
if (goodReplace) {
@@ -1119,7 +1108,7 @@ typedef struct {
isGood = YES;
}
}
- return isGood;
+ return isGood;
}
- (BOOL)replaceLabelAtIndex:(NSUInteger)idx withLabel:(CFStringRef)label {
@@ -1127,11 +1116,11 @@ typedef struct {
NSUInteger count = [self count];
if (idx < count) {
#if GTM_IPHONE_SDK
- bool goodReplace = ABMultiValueReplaceLabelAtIndex(multiValue_,
+ bool goodReplace = ABMultiValueReplaceLabelAtIndex(multiValue_,
label, idx);
#else // GTM_IPHONE_SDK
- bool goodReplace
- = ABMultiValueReplaceLabel((ABMutableMultiValueRef)multiValue_,
+ bool goodReplace
+ = ABMultiValueReplaceLabel((ABMutableMultiValueRef)multiValue_,
(CFTypeRef)label, idx);
#endif // GTM_IPHONE_SDK
if (goodReplace) {
@@ -1139,14 +1128,14 @@ typedef struct {
isGood = YES;
}
}
- return isGood;
+ return isGood;
}
-
+
- (unsigned long*)mutations {
return &mutations_;
}
@end
-
+
@implementation GTMABMultiValueEnumerator
@@ -1180,19 +1169,18 @@ typedef struct {
[super dealloc];
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
-- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
- objects:(id *)stackbuf
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state
+ objects:(id *)stackbuf
count:(NSUInteger)len {
NSUInteger i;
if (!ref_) {
count_ = [enumeree_ count];
ref_ = [enumeree_ multiValueRef];
}
-
+
for (i = 0; state->state < count_ && i < len; ++i, ++state->state) {
if (useLabels_) {
- stackbuf[i] = GTMCFAutorelease(ABMultiValueCopyLabelAtIndex(ref_,
+ stackbuf[i] = GTMCFAutorelease(ABMultiValueCopyLabelAtIndex(ref_,
state->state));
} else {
// TODO(dmaclach) Check this on Mac Desktop and use fast path if we can
@@ -1203,12 +1191,11 @@ typedef struct {
stackbuf[i] = [enumeree_ valueAtIndex:state->state];
}
}
-
+
state->itemsPtr = stackbuf;
state->mutationsPtr = [enumeree_ mutations];
return i;
}
-#endif // MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5
- (id)nextObject {
id value = nil;
@@ -1227,7 +1214,7 @@ typedef struct {
}
if (index_ < count_) {
if (useLabels_) {
- value = GTMCFAutorelease(ABMultiValueCopyLabelAtIndex(ref_,
+ value = GTMCFAutorelease(ABMultiValueCopyLabelAtIndex(ref_,
index_));
} else {
// TODO(dmaclach) Check this on Mac Desktop and use fast path if we can
diff --git a/AddressBook/GTMABAddressBookTest.m b/AddressBook/GTMABAddressBookTest.m
index 7711648..de5a2ab 100644
--- a/AddressBook/GTMABAddressBookTest.m
+++ b/AddressBook/GTMABAddressBookTest.m
@@ -37,6 +37,24 @@ static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName";
@implementation GTMABAddressBookTest
+
+#if GTM_IPHONE_SDK
+
+// On iOS we need to check if we have access to the Address Book before running any tests.
+// See
+// third_party/objective_c/google_toolbox_for_mac/UnitTesting/GTMIPhoneUnitTestMain.m
+// for a way this can be provided via entitlements.
+
++ (void)setUp {
+ [super setUp];
+ ABAuthorizationStatus status = ABAddressBookGetAuthorizationStatus();
+ if(status != kABAuthorizationStatusAuthorized) {
+ [NSException raise:NSInternalInconsistencyException format:@"Don't have Address Book Access"];
+ }
+}
+
+#endif // GTM_IPHONE_SDK
+
- (void)setUp {
// Create a book forcing it out of it's autorelease pool.
// I force it out of the release pool, so that we will see any errors
@@ -45,17 +63,17 @@ static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName";
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
book_ = [[GTMABAddressBook addressBook] retain];
[pool release];
- STAssertNotNil(book_, nil);
+ XCTAssertNotNil(book_);
NSArray *people
= [book_ peopleWithCompositeNameWithPrefix:kGTMABTestFirstName];
GTMABPerson *person;
- GTM_FOREACH_OBJECT(person, people) {
+ for (person in people) {
[book_ removeRecord:person];
}
NSArray *groups
= [book_ groupsWithCompositeNameWithPrefix:kGTMABTestGroupName];
GTMABGroup *group;
- GTM_FOREACH_OBJECT(group, groups) {
+ for (group in groups) {
[book_ removeRecord:group];
}
[book_ save];
@@ -66,340 +84,339 @@ static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName";
}
- (void)testGenericAddressBook {
- STAssertEqualObjects([GTMABAddressBook localizedLabel:(NSString *)kABHomeLabel],
- @"home",
- nil);
- STAssertThrows([GTMABRecord recordWithRecord:nil], nil);
+ XCTAssertEqualObjects([GTMABAddressBook localizedLabel:(NSString *)kABHomeLabel],
+ @"home");
+ XCTAssertThrows([GTMABRecord recordWithRecord:nil]);
}
- (void)testAddingAndRemovingPerson {
// Create a person
GTMABPerson *person = [GTMABPerson personWithFirstName:kGTMABTestFirstName
lastName:kGTMABTestLastName];
- STAssertNotNil(person, nil);
+ XCTAssertNotNil(person);
// Add person
NSArray *people = [book_ people];
- STAssertFalse([people containsObject:person], nil);
- STAssertTrue([book_ addRecord:person], nil);
+ XCTAssertFalse([people containsObject:person]);
+ XCTAssertTrue([book_ addRecord:person]);
#if GTM_IPHONE_SDK && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_3_2)
- // Normally this next line would be STAssertTrue, however due to
+ // Normally this next line would be XCTAssertTrue, however due to
// Radar 6200638: ABAddressBookHasUnsavedChanges doesn't work
// We will check to make sure it stays broken ;-)
- STAssertFalse([book_ hasUnsavedChanges], nil);
+ XCTAssertFalse([book_ hasUnsavedChanges]);
#else // GTM_IPHONE_SDK
- STAssertTrue([book_ hasUnsavedChanges], nil);
+ XCTAssertTrue([book_ hasUnsavedChanges]);
#endif // GTM_IPHONE_SDK
people = [book_ people];
- STAssertNotNil(people, nil);
+ XCTAssertNotNil(people);
#if GTM_IPHONE_SDK
- // Normally this next line would be STAssertTrue, however due to
+ // Normally this next line would be XCTAssertTrue, however due to
// Radar 6200703: ABAddressBookAddRecord doesn't add an item to the people
// array until it's saved
// We will check to make sure it stays broken ;-)
- STAssertFalse([people containsObject:person], nil);
+ XCTAssertFalse([people containsObject:person]);
#else // GTM_IPHONE_SDK
- STAssertTrue([people containsObject:person], nil);
+ XCTAssertTrue([people containsObject:person]);
#endif // GTM_IPHONE_SDK
// Save book_
- STAssertTrue([book_ save], nil);
+ XCTAssertTrue([book_ save]);
people = [book_ people];
- STAssertNotNil(people, nil);
- STAssertTrue([people containsObject:person], nil);
+ XCTAssertNotNil(people);
+ XCTAssertTrue([people containsObject:person]);
people = [book_ peopleWithCompositeNameWithPrefix:kGTMABTestFirstName];
- STAssertEqualObjects([people objectAtIndex:0], person, nil);
+ XCTAssertEqualObjects([people objectAtIndex:0], person);
GTMABRecordID recordID = [person recordID];
- STAssertNotEquals(recordID, kGTMABRecordInvalidID, nil);
+ XCTAssertNotEqual(recordID, kGTMABRecordInvalidID);
GTMABRecord *record = [book_ personForId:recordID];
- STAssertEqualObjects(record, person, nil);
+ XCTAssertEqualObjects(record, person);
// Remove person
- STAssertTrue([book_ removeRecord:person], nil);
+ XCTAssertTrue([book_ removeRecord:person]);
people = [book_ peopleWithCompositeNameWithPrefix:kGTMABTestFirstName];
- STAssertEquals([people count], (NSUInteger)0, nil);
+ XCTAssertEqual([people count], (NSUInteger)0);
#if GTM_IPHONE_SDK && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_3_2)
- // Normally this next line would be STAssertTrue, however due to
+ // Normally this next line would be XCTAssertTrue, however due to
// Radar 6200638: ABAddressBookHasUnsavedChanges doesn't work
// We will check to make sure it stays broken ;-)
- STAssertFalse([book_ hasUnsavedChanges], nil);
+ XCTAssertFalse([book_ hasUnsavedChanges]);
#else // GTM_IPHONE_SDK
- STAssertTrue([book_ hasUnsavedChanges], nil);
+ XCTAssertTrue([book_ hasUnsavedChanges]);
#endif // GTM_IPHONE_SDK
people = [book_ people];
- STAssertFalse([people containsObject:person], nil);
+ XCTAssertFalse([people containsObject:person]);
// Save Book
- STAssertTrue([book_ save], nil);
+ XCTAssertTrue([book_ save]);
people = [book_ people];
- STAssertFalse([book_ hasUnsavedChanges], nil);
- STAssertFalse([people containsObject:person], nil);
+ XCTAssertFalse([book_ hasUnsavedChanges]);
+ XCTAssertFalse([people containsObject:person]);
record = [book_ personForId:recordID];
- STAssertNil(record, nil);
+ XCTAssertNil(record);
// Bogus data
- STAssertFalse([book_ addRecord:nil], nil);
- STAssertFalse([book_ removeRecord:nil], nil);
+ XCTAssertFalse([book_ addRecord:nil]);
+ XCTAssertFalse([book_ removeRecord:nil]);
- STAssertNotNULL([book_ addressBookRef], nil);
+ XCTAssertNotNULL([book_ addressBookRef]);
}
- (void)testAddingAndRemovingGroup {
// Create a group
GTMABGroup *group = [GTMABGroup groupNamed:kGTMABTestGroupName];
- STAssertNotNil(group, nil);
+ XCTAssertNotNil(group);
// Add group
NSArray *groups = [book_ groups];
- STAssertFalse([groups containsObject:group], nil);
- STAssertTrue([book_ addRecord:group], nil);
+ XCTAssertFalse([groups containsObject:group]);
+ XCTAssertTrue([book_ addRecord:group]);
#if GTM_IPHONE_SDK && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_3_2)
- // Normally this next line would be STAssertTrue, however due to
+ // Normally this next line would be XCTAssertTrue, however due to
// Radar 6200638: ABAddressBookHasUnsavedChanges doesn't work
// We will check to make sure it stays broken ;-)
- STAssertFalse([book_ hasUnsavedChanges], nil);
+ XCTAssertFalse([book_ hasUnsavedChanges]);
#else // GTM_IPHONE_SDK
- STAssertTrue([book_ hasUnsavedChanges], nil);
+ XCTAssertTrue([book_ hasUnsavedChanges]);
#endif // GTM_IPHONE_SDK
groups = [book_ groups];
- STAssertNotNil(groups, nil);
+ XCTAssertNotNil(groups);
#if GTM_IPHONE_SDK
- // Normally this next line would be STAssertTrue, however due to
+ // Normally this next line would be XCTAssertTrue, however due to
// Radar 6200703: ABAddressBookAddRecord doesn't add an item to the groups
// array until it's saved
// We will check to make sure it stays broken ;-)
- STAssertFalse([groups containsObject:group], nil);
+ XCTAssertFalse([groups containsObject:group]);
#else // GTM_IPHONE_SDK
- STAssertTrue([groups containsObject:group], nil);
+ XCTAssertTrue([groups containsObject:group]);
#endif // GTM_IPHONE_SDK
// Save book_
- STAssertTrue([book_ save], nil);
+ XCTAssertTrue([book_ save]);
groups = [book_ groups];
- STAssertNotNil(groups, nil);
- STAssertTrue([groups containsObject:group], nil);
+ XCTAssertNotNil(groups);
+ XCTAssertTrue([groups containsObject:group]);
groups = [book_ groupsWithCompositeNameWithPrefix:kGTMABTestGroupName];
- STAssertEqualObjects([groups objectAtIndex:0], group, nil);
+ XCTAssertEqualObjects([groups objectAtIndex:0], group);
GTMABRecordID recordID = [group recordID];
- STAssertNotEquals(recordID, kGTMABRecordInvalidID, nil);
+ XCTAssertNotEqual(recordID, kGTMABRecordInvalidID);
GTMABRecord *record = [book_ groupForId:recordID];
- STAssertEqualObjects(record, group, nil);
+ XCTAssertEqualObjects(record, group);
// Remove group
- STAssertTrue([book_ removeRecord:group], nil);
+ XCTAssertTrue([book_ removeRecord:group]);
#if GTM_IPHONE_SDK && (__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_3_2)
- // Normally this next line would be STAssertTrue, however due to
+ // Normally this next line would be XCTAssertTrue, however due to
// Radar 6200638: ABAddressBookHasUnsavedChanges doesn't work
// We will check to make sure it stays broken ;-)
- STAssertFalse([book_ hasUnsavedChanges], nil);
+ XCTAssertFalse([book_ hasUnsavedChanges]);
#else // GTM_IPHONE_SDK
- STAssertTrue([book_ hasUnsavedChanges], nil);
+ XCTAssertTrue([book_ hasUnsavedChanges]);
#endif // GTM_IPHONE_SDK
groups = [book_ groups];
- STAssertFalse([groups containsObject:group], nil);
+ XCTAssertFalse([groups containsObject:group]);
// Save Book
- STAssertTrue([book_ save], nil);
+ XCTAssertTrue([book_ save]);
groups = [book_ groups];
- STAssertFalse([book_ hasUnsavedChanges], nil);
- STAssertFalse([groups containsObject:group], nil);
+ XCTAssertFalse([book_ hasUnsavedChanges]);
+ XCTAssertFalse([groups containsObject:group]);
groups = [book_ groupsWithCompositeNameWithPrefix:kGTMABTestGroupName];
- STAssertEquals([groups count], (NSUInteger)0, nil);
+ XCTAssertEqual([groups count], (NSUInteger)0);
record = [book_ groupForId:recordID];
- STAssertNil(record, nil);
+ XCTAssertNil(record);
}
- (void)testPerson {
GTMABPerson *person = [[[GTMABPerson alloc] initWithRecord:nil] autorelease];
- STAssertNil(person, nil);
+ XCTAssertNil(person);
person = [GTMABPerson personWithFirstName:kGTMABTestFirstName
lastName:nil];
- STAssertNotNil(person, nil);
- STAssertEqualObjects([person compositeName], kGTMABTestFirstName, nil);
+ XCTAssertNotNil(person);
+ XCTAssertEqualObjects([person compositeName], kGTMABTestFirstName);
NSString *firstName = [person valueForProperty:kGTMABPersonFirstNameProperty];
- STAssertEqualObjects(firstName, kGTMABTestFirstName, nil);
+ XCTAssertEqualObjects(firstName, kGTMABTestFirstName);
NSString *lastName = [person valueForProperty:kGTMABPersonLastNameProperty];
- STAssertNil(lastName, nil);
- STAssertTrue([person removeValueForProperty:kGTMABPersonFirstNameProperty], nil);
- STAssertFalse([person removeValueForProperty:kGTMABPersonFirstNameProperty], nil);
- STAssertFalse([person removeValueForProperty:kGTMABPersonLastNameProperty], nil);
- STAssertFalse([person setValue:nil forProperty:kGTMABPersonFirstNameProperty], nil);
- STAssertFalse([person setValue:[NSNumber numberWithInt:1]
- forProperty:kGTMABPersonFirstNameProperty], nil);
- STAssertFalse([person setValue:@"Bart"
- forProperty:kGTMABPersonBirthdayProperty], nil);
+ XCTAssertNil(lastName);
+ XCTAssertTrue([person removeValueForProperty:kGTMABPersonFirstNameProperty]);
+ XCTAssertFalse([person removeValueForProperty:kGTMABPersonFirstNameProperty]);
+ XCTAssertFalse([person removeValueForProperty:kGTMABPersonLastNameProperty]);
+ XCTAssertFalse([person setValue:nil forProperty:kGTMABPersonFirstNameProperty]);
+ XCTAssertFalse([person setValue:[NSNumber numberWithInt:1]
+ forProperty:kGTMABPersonFirstNameProperty]);
+ XCTAssertFalse([person setValue:@"Bart"
+ forProperty:kGTMABPersonBirthdayProperty]);
GTMABPropertyType property
= [GTMABPerson typeOfProperty:kGTMABPersonLastNameProperty];
- STAssertEquals(property, (GTMABPropertyType)kGTMABStringPropertyType, nil);
+ XCTAssertEqual(property, (GTMABPropertyType)kGTMABStringPropertyType);
NSString *string
= [GTMABPerson localizedPropertyName:kGTMABPersonLastNameProperty];
- STAssertEqualObjects(string, @"Last", nil);
+ XCTAssertEqualObjects(string, @"Last");
string = [GTMABPerson localizedPropertyName:kGTMABRecordInvalidID];
#if GTM_IPHONE_SDK
- STAssertEqualObjects(string, kGTMABUnknownPropertyName, nil);
+ XCTAssertEqualObjects(string, kGTMABUnknownPropertyName);
#else // GTM_IPHONE_SDK
- STAssertEqualObjects(string, kGTMABRecordInvalidID, nil);
+ XCTAssertEqualObjects(string, kGTMABRecordInvalidID);
#endif // GTM_IPHONE_SDK
string = [person description];
- STAssertNotNil(string, nil);
+ XCTAssertNotNil(string);
GTMABPersonCompositeNameFormat format = [GTMABPerson compositeNameFormat];
- STAssertTrue(format == kABPersonCompositeNameFormatFirstNameFirst ||
- format == kABPersonCompositeNameFormatLastNameFirst, nil);
+ XCTAssertTrue(format == kABPersonCompositeNameFormatFirstNameFirst ||
+ format == kABPersonCompositeNameFormatLastNameFirst);
NSData *data = [person imageData];
- STAssertNil(data, nil);
- STAssertTrue([person setImageData:nil], nil);
+ XCTAssertNil(data);
+ XCTAssertTrue([person setImageData:nil]);
data = [person imageData];
- STAssertNil(data, nil);
+ XCTAssertNil(data);
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *phonePath = [bundle pathForResource:@"phone" ofType:@"png"];
- STAssertNotNil(phonePath, nil);
+ XCTAssertNotNil(phonePath);
GTMABImage *image
= [[[GTMABImage alloc] initWithContentsOfFile:phonePath] autorelease];
- STAssertNotNil(image, nil);
+ XCTAssertNotNil(image);
#if GTM_IPHONE_SDK
data = UIImagePNGRepresentation(image);
#else // GTM_IPHONE_SDK
data = [image TIFFRepresentation];
#endif // GTM_IPHONE_SDK
- STAssertTrue([person setImageData:data], nil);
+ XCTAssertTrue([person setImageData:data]);
NSData *data2 = [person imageData];
- STAssertEqualObjects(data, data2, nil);
- STAssertTrue([person setImageData:nil], nil);
+ XCTAssertEqualObjects(data, data2);
+ XCTAssertTrue([person setImageData:nil]);
data = [person imageData];
- STAssertNil(data, nil);
+ XCTAssertNil(data);
- STAssertTrue([person setImage:image], nil);
+ XCTAssertTrue([person setImage:image]);
GTMABImage *image2 = [person image];
- STAssertNotNil(image2, nil);
+ XCTAssertNotNil(image2);
#if GTM_IPHONE_SDK
- STAssertEqualObjects(UIImagePNGRepresentation(image),
- UIImagePNGRepresentation(image2), nil);
+ XCTAssertEqualObjects(UIImagePNGRepresentation(image),
+ UIImagePNGRepresentation(image2));
#else // GTM_IPHONE_SDK
- STAssertEqualObjects([image TIFFRepresentation],
- [image2 TIFFRepresentation], nil);
+ XCTAssertEqualObjects([image TIFFRepresentation],
+ [image2 TIFFRepresentation]);
#endif // GTM_IPHONE_SDK
person = [GTMABPerson personWithFirstName:kGTMABTestFirstName
lastName:kGTMABTestLastName];
data = [NSData dataWithBytes:"a" length:1];
- STAssertFalse([person setImageData:data], nil);
+ XCTAssertFalse([person setImageData:data]);
GTMABMutableMultiValue *value
= [GTMABMutableMultiValue valueWithPropertyType:kGTMABStringPropertyType];
- STAssertNotNil(value, nil);
- STAssertNotEquals([value addValue:@"222-222-2222"
+ XCTAssertNotNil(value);
+ XCTAssertNotEqual([value addValue:@"222-222-2222"
withLabel:(CFStringRef)kABHomeLabel],
- kGTMABMultiValueInvalidIdentifier, nil);
- STAssertNotEquals([value addValue:@"333-333-3333"
+ kGTMABMultiValueInvalidIdentifier);
+ XCTAssertNotEqual([value addValue:@"333-333-3333"
withLabel:(CFStringRef)kABWorkLabel],
- kGTMABMultiValueInvalidIdentifier, nil);
- STAssertTrue([person setValue:value
- forProperty:kGTMABPersonPhoneProperty], nil);
+ kGTMABMultiValueInvalidIdentifier);
+ XCTAssertTrue([person setValue:value
+ forProperty:kGTMABPersonPhoneProperty]);
id value2 = [person valueForProperty:kGTMABPersonPhoneProperty];
- STAssertNotNil(value2, nil);
- STAssertEqualObjects(value, value2, nil);
- STAssertEquals([value hash], [value2 hash], nil);
- STAssertNotEquals([person hash], (NSUInteger)0, nil);
+ XCTAssertNotNil(value2);
+ XCTAssertEqualObjects(value, value2);
+ XCTAssertEqual([value hash], [value2 hash]);
+ XCTAssertNotEqual([person hash], (NSUInteger)0);
}
- (void)testGroup {
GTMABGroup *group = [[[GTMABGroup alloc] initWithRecord:nil] autorelease];
- STAssertNil(group, nil);
+ XCTAssertNil(group);
group = [GTMABGroup groupNamed:kGTMABTestGroupName];
- STAssertNotNil(group, nil);
- STAssertEqualObjects([group compositeName], kGTMABTestGroupName, nil);
+ XCTAssertNotNil(group);
+ XCTAssertEqualObjects([group compositeName], kGTMABTestGroupName);
NSString *name = [group valueForProperty:kABGroupNameProperty];
- STAssertEqualObjects(name, kGTMABTestGroupName, nil);
+ XCTAssertEqualObjects(name, kGTMABTestGroupName);
NSString *lastName = [group valueForProperty:kGTMABPersonLastNameProperty];
- STAssertNil(lastName, nil);
- STAssertTrue([group removeValueForProperty:kABGroupNameProperty], nil);
- STAssertFalse([group removeValueForProperty:kABGroupNameProperty], nil);
- STAssertFalse([group removeValueForProperty:kGTMABPersonLastNameProperty], nil);
- STAssertFalse([group setValue:nil forProperty:kABGroupNameProperty], nil);
- STAssertFalse([group setValue:[NSNumber numberWithInt:1]
- forProperty:kABGroupNameProperty], nil);
- STAssertFalse([group setValue:@"Bart"
- forProperty:kGTMABPersonBirthdayProperty], nil);
+ XCTAssertNil(lastName);
+ XCTAssertTrue([group removeValueForProperty:kABGroupNameProperty]);
+ XCTAssertFalse([group removeValueForProperty:kABGroupNameProperty]);
+ XCTAssertFalse([group removeValueForProperty:kGTMABPersonLastNameProperty]);
+ XCTAssertFalse([group setValue:nil forProperty:kABGroupNameProperty]);
+ XCTAssertFalse([group setValue:[NSNumber numberWithInt:1]
+ forProperty:kABGroupNameProperty]);
+ XCTAssertFalse([group setValue:@"Bart"
+ forProperty:kGTMABPersonBirthdayProperty]);
ABPropertyType property = [GTMABGroup typeOfProperty:kABGroupNameProperty];
- STAssertEquals(property, (ABPropertyType)kGTMABStringPropertyType, nil);
+ XCTAssertEqual(property, (ABPropertyType)kGTMABStringPropertyType);
property = [GTMABGroup typeOfProperty:kGTMABPersonLastNameProperty];
- STAssertEquals(property, (ABPropertyType)kGTMABInvalidPropertyType, nil);
+ XCTAssertEqual(property, (ABPropertyType)kGTMABInvalidPropertyType);
NSString *string = [GTMABGroup localizedPropertyName:kABGroupNameProperty];
- STAssertEqualObjects(string, @"Name", nil);
+ XCTAssertEqualObjects(string, @"Name");
string = [GTMABGroup localizedPropertyName:kGTMABPersonLastNameProperty];
- STAssertEqualObjects(string, kGTMABUnknownPropertyName, nil);
+ XCTAssertEqualObjects(string, kGTMABUnknownPropertyName);
string = [GTMABGroup localizedPropertyName:kGTMABRecordInvalidID];
- STAssertEqualObjects(string, kGTMABUnknownPropertyName, nil);
+ XCTAssertEqualObjects(string, kGTMABUnknownPropertyName);
string = [group description];
- STAssertNotNil(string, nil);
+ XCTAssertNotNil(string);
// Adding and removing members
group = [GTMABGroup groupNamed:kGTMABTestGroupName];
NSArray *members = [group members];
- STAssertEquals([members count], (NSUInteger)0, @"Members: %@", members);
+ XCTAssertEqual([members count], (NSUInteger)0, @"Members: %@", members);
- STAssertFalse([group addMember:nil], nil);
+ XCTAssertFalse([group addMember:nil]);
members = [group members];
- STAssertEquals([members count], (NSUInteger)0, @"Members: %@", members);
+ XCTAssertEqual([members count], (NSUInteger)0, @"Members: %@", members);
GTMABPerson *person = [GTMABPerson personWithFirstName:kGTMABTestFirstName
lastName:kGTMABTestLastName];
- STAssertNotNil(person, nil);
- STAssertTrue([book_ addRecord:person], nil);
- STAssertTrue([book_ save], nil);
- STAssertTrue([book_ addRecord:group], nil);
- STAssertTrue([book_ save], nil);
- STAssertTrue([group addMember:person], nil);
- STAssertTrue([book_ save], nil);
+ XCTAssertNotNil(person);
+ XCTAssertTrue([book_ addRecord:person]);
+ XCTAssertTrue([book_ save]);
+ XCTAssertTrue([book_ addRecord:group]);
+ XCTAssertTrue([book_ save]);
+ XCTAssertTrue([group addMember:person]);
+ XCTAssertTrue([book_ save]);
members = [group members];
- STAssertEquals([members count], (NSUInteger)1, @"Members: %@", members);
- STAssertTrue([group removeMember:person], nil);
- STAssertFalse([group removeMember:person], nil);
- STAssertFalse([group removeMember:nil], nil);
- STAssertTrue([book_ removeRecord:group], nil);
- STAssertTrue([book_ removeRecord:person], nil);
- STAssertTrue([book_ save], nil);
+ XCTAssertEqual([members count], (NSUInteger)1, @"Members: %@", members);
+ XCTAssertTrue([group removeMember:person]);
+ XCTAssertFalse([group removeMember:person]);
+ XCTAssertFalse([group removeMember:nil]);
+ XCTAssertTrue([book_ removeRecord:group]);
+ XCTAssertTrue([book_ removeRecord:person]);
+ XCTAssertTrue([book_ save]);
}
- (void)testMultiValues {
- STAssertThrows([[GTMABMultiValue alloc] init], nil);
- STAssertThrows([[GTMABMutableMultiValue alloc] init], nil);
+ XCTAssertThrows([[GTMABMultiValue alloc] init]);
+ XCTAssertThrows([[GTMABMutableMultiValue alloc] init]);
GTMABMultiValue *value = [[GTMABMultiValue alloc] initWithMultiValue:nil];
- STAssertNil(value, nil);
+ XCTAssertNil(value);
GTMABMutableMultiValue *mutValue
= [GTMABMutableMultiValue valueWithPropertyType:kGTMABInvalidPropertyType];
- STAssertNil(mutValue, nil);
+ XCTAssertNil(mutValue);
mutValue
= [[[GTMABMutableMultiValue alloc]
initWithMutableMultiValue:nil] autorelease];
- STAssertNil(mutValue, nil);
+ XCTAssertNil(mutValue);
mutValue
= [[[GTMABMutableMultiValue alloc]
initWithMultiValue:nil] autorelease];
- STAssertNil(mutValue, nil);
+ XCTAssertNil(mutValue);
#if GTM_IPHONE_SDK
// Only the IPhone version actually allows you to check types of a multivalue
// before you stick anything in it
@@ -417,154 +434,154 @@ static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName";
};
for (size_t i = 0; i < sizeof(types) / sizeof(GTMABPropertyType); ++i) {
mutValue = [GTMABMutableMultiValue valueWithPropertyType:types[i]];
- STAssertNotNil(mutValue, nil);
+ XCTAssertNotNil(mutValue);
// Oddly the Apple APIs allow you to create a mutable multi value with
// either a property type of kABFooPropertyType or kABMultiFooPropertyType
// and apparently you get back basically the same thing. However if you
// ask a type that you created with kABMultiFooPropertyType for it's type
// it returns just kABFooPropertyType.
- STAssertEquals([mutValue propertyType],
- (GTMABPropertyType)(types[i] & ~kABMultiValueMask), nil);
+ XCTAssertEqual([mutValue propertyType],
+ (GTMABPropertyType)(types[i] & ~kABMultiValueMask));
}
#endif // GTM_IPHONE_SDK
mutValue
= [GTMABMutableMultiValue valueWithPropertyType:kGTMABStringPropertyType];
- STAssertNotNil(mutValue, nil);
+ XCTAssertNotNil(mutValue);
value = [[mutValue copy] autorelease];
- STAssertEqualObjects([value class], [GTMABMultiValue class], nil);
+ XCTAssertEqualObjects([value class], [GTMABMultiValue class]);
mutValue = [[value mutableCopy] autorelease];
- STAssertEqualObjects([mutValue class], [GTMABMutableMultiValue class], nil);
- STAssertEquals([mutValue count], (NSUInteger)0, nil);
- STAssertNil([mutValue valueAtIndex:0], nil);
- STAssertNil([mutValue labelAtIndex:0], nil);
+ XCTAssertEqualObjects([mutValue class], [GTMABMutableMultiValue class]);
+ XCTAssertEqual([mutValue count], (NSUInteger)0);
+ XCTAssertNil([mutValue valueAtIndex:0]);
+ XCTAssertNil([mutValue labelAtIndex:0]);
#if GTM_IPHONE_SDK
- STAssertEquals([mutValue identifierAtIndex:0],
- kGTMABMultiValueInvalidIdentifier, nil);
- STAssertEquals([mutValue propertyType],
- (GTMABPropertyType)kGTMABStringPropertyType, nil);
+ XCTAssertEqual([mutValue identifierAtIndex:0],
+ kGTMABMultiValueInvalidIdentifier);
+ XCTAssertEqual([mutValue propertyType],
+ (GTMABPropertyType)kGTMABStringPropertyType);
#else // GTM_IPHONE_SDK
- STAssertEqualObjects([mutValue identifierAtIndex:0],
- kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqualObjects([mutValue identifierAtIndex:0],
+ kGTMABMultiValueInvalidIdentifier);
#endif // GTM_IPHONE_SDK
GTMABMultiValueIdentifier ident
= [mutValue addValue:nil withLabel:(CFStringRef)kABHomeLabel];
#if GTM_IPHONE_SDK
- STAssertEquals(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqual(ident, kGTMABMultiValueInvalidIdentifier);
#else // GTM_IPHONE_SDK
- STAssertEqualObjects(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqualObjects(ident, kGTMABMultiValueInvalidIdentifier);
#endif // GTM_IPHONE_SDK
ident = [mutValue addValue:@"val1"
withLabel:nil];
#if GTM_IPHONE_SDK
- STAssertEquals(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqual(ident, kGTMABMultiValueInvalidIdentifier);
#else // GTM_IPHONE_SDK
- STAssertEqualObjects(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqualObjects(ident, kGTMABMultiValueInvalidIdentifier);
#endif // GTM_IPHONE_SDK
ident = [mutValue insertValue:@"val1"
withLabel:nil
atIndex:0];
#if GTM_IPHONE_SDK
- STAssertEquals(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqual(ident, kGTMABMultiValueInvalidIdentifier);
#else // GTM_IPHONE_SDK
- STAssertEqualObjects(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqualObjects(ident, kGTMABMultiValueInvalidIdentifier);
#endif // GTM_IPHONE_SDK
ident = [mutValue insertValue:nil
withLabel:(CFStringRef)kABHomeLabel
atIndex:0];
#if GTM_IPHONE_SDK
- STAssertEquals(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqual(ident, kGTMABMultiValueInvalidIdentifier);
#else // GTM_IPHONE_SDK
- STAssertEqualObjects(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqualObjects(ident, kGTMABMultiValueInvalidIdentifier);
#endif // GTM_IPHONE_SDK
ident = [mutValue addValue:@"val1"
withLabel:(CFStringRef)kABHomeLabel];
#if GTM_IPHONE_SDK
- STAssertNotEquals(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertNotEqual(ident, kGTMABMultiValueInvalidIdentifier);
#else // GTM_IPHONE_SDK
- STAssertNotEqualObjects(ident, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertNotEqualObjects(ident, kGTMABMultiValueInvalidIdentifier);
#endif // GTM_IPHONE_SDK
GTMABMultiValueIdentifier identCheck = [mutValue identifierAtIndex:0];
#if GTM_IPHONE_SDK
- STAssertEquals(ident, identCheck, nil);
+ XCTAssertEqual(ident, identCheck);
#else // GTM_IPHONE_SDK
- STAssertEqualObjects(ident, identCheck, nil);
+ XCTAssertEqualObjects(ident, identCheck);
#endif // GTM_IPHONE_SDK
NSUInteger idx = [mutValue indexForIdentifier:ident];
- STAssertEquals(idx, (NSUInteger)0, nil);
- STAssertTrue([mutValue replaceLabelAtIndex:0
- withLabel:(CFStringRef)kABWorkLabel], nil);
- STAssertFalse([mutValue replaceLabelAtIndex:10
- withLabel:(CFStringRef)kABWorkLabel], nil);
- STAssertTrue([mutValue replaceValueAtIndex:0
- withValue:@"newVal1"], nil);
- STAssertFalse([mutValue replaceValueAtIndex:10
- withValue:@"newVal1"], nil);
-
- STAssertEqualObjects([mutValue valueForIdentifier:ident], @"newVal1", nil);
- STAssertEqualObjects([mutValue labelForIdentifier:ident],
- (NSString *)kABWorkLabel, nil);
+ XCTAssertEqual(idx, (NSUInteger)0);
+ XCTAssertTrue([mutValue replaceLabelAtIndex:0
+ withLabel:(CFStringRef)kABWorkLabel]);
+ XCTAssertFalse([mutValue replaceLabelAtIndex:10
+ withLabel:(CFStringRef)kABWorkLabel]);
+ XCTAssertTrue([mutValue replaceValueAtIndex:0
+ withValue:@"newVal1"]);
+ XCTAssertFalse([mutValue replaceValueAtIndex:10
+ withValue:@"newVal1"]);
+
+ XCTAssertEqualObjects([mutValue valueForIdentifier:ident], @"newVal1");
+ XCTAssertEqualObjects([mutValue labelForIdentifier:ident],
+ (NSString *)kABWorkLabel);
GTMABMultiValueIdentifier ident2
= [mutValue insertValue:@"val2"
withLabel:(CFStringRef)kABOtherLabel
atIndex:0];
- STAssertNotEquals(ident2, kGTMABMultiValueInvalidIdentifier, nil);
- STAssertNotEquals(ident2, ident, nil);
+ XCTAssertNotEqual(ident2, kGTMABMultiValueInvalidIdentifier);
+ XCTAssertNotEqual(ident2, ident);
GTMABMultiValueIdentifier ident3
= [mutValue insertValue:@"val3"
withLabel:(CFStringRef)kGTMABPersonPhoneMainLabel
atIndex:10];
#if GTM_IPHONE_SDK
- STAssertEquals(ident3, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqual(ident3, kGTMABMultiValueInvalidIdentifier);
#else // GTM_IPHONE_SDK
- STAssertEqualObjects(ident3, kGTMABMultiValueInvalidIdentifier, nil);
+ XCTAssertEqualObjects(ident3, kGTMABMultiValueInvalidIdentifier);
#endif // GTM_IPHONE_SDK
NSUInteger idx3 = [mutValue indexForIdentifier:ident3];
- STAssertEquals(idx3, (NSUInteger)NSNotFound, nil);
- STAssertTrue([mutValue removeValueAndLabelAtIndex:1], nil);
- STAssertFalse([mutValue removeValueAndLabelAtIndex:1], nil);
+ XCTAssertEqual(idx3, (NSUInteger)NSNotFound);
+ XCTAssertTrue([mutValue removeValueAndLabelAtIndex:1]);
+ XCTAssertFalse([mutValue removeValueAndLabelAtIndex:1]);
NSUInteger idx4
= [mutValue indexForIdentifier:kGTMABMultiValueInvalidIdentifier];
- STAssertEquals(idx4, (NSUInteger)NSNotFound, nil);
+ XCTAssertEqual(idx4, (NSUInteger)NSNotFound);
- STAssertNotNULL([mutValue multiValueRef], nil);
+ XCTAssertNotNULL([mutValue multiValueRef]);
// Enumerator test
mutValue
= [GTMABMutableMultiValue valueWithPropertyType:kGTMABIntegerPropertyType];
- STAssertNotNil(mutValue, nil);
+ XCTAssertNotNil(mutValue);
for (int i = 0; i < 100; i++) {
NSString *label = [NSString stringWithFormat:@"label %d", i];
NSNumber *val = [NSNumber numberWithInt:i];
- STAssertNotEquals([mutValue addValue:val
+ XCTAssertNotEqual([mutValue addValue:val
withLabel:(CFStringRef)label],
- kGTMABMultiValueInvalidIdentifier, nil);
+ kGTMABMultiValueInvalidIdentifier);
}
int count = 0;
NSString *label;
- GTM_FOREACH_ENUMEREE(label, [mutValue labelEnumerator]) {
+ for (label in [mutValue labelEnumerator]) {
NSString *testLabel = [NSString stringWithFormat:@"label %d", count++];
- STAssertEqualObjects(label, testLabel, nil);
+ XCTAssertEqualObjects(label, testLabel);
}
count = 0;
value = [[mutValue copy] autorelease];
NSNumber *val;
- GTM_FOREACH_ENUMEREE(val, [value valueEnumerator]) {
- STAssertEqualObjects(val, [NSNumber numberWithInt:count++], nil);
+ for (val in [value valueEnumerator]) {
+ XCTAssertEqualObjects(val, [NSNumber numberWithInt:count++]);
}
// Test messing with the values while we're enumerating them
NSEnumerator *labelEnum = [mutValue labelEnumerator];
NSEnumerator *valueEnum = [mutValue valueEnumerator];
- STAssertNotNil(labelEnum, nil);
- STAssertNotNil(valueEnum, nil);
- STAssertNotNil([labelEnum nextObject], nil);
- STAssertNotNil([valueEnum nextObject], nil);
- STAssertTrue([mutValue removeValueAndLabelAtIndex:0], nil);
- STAssertThrows([labelEnum nextObject], nil);
- STAssertThrows([valueEnum nextObject], nil);
+ XCTAssertNotNil(labelEnum);
+ XCTAssertNotNil(valueEnum);
+ XCTAssertNotNil([labelEnum nextObject]);
+ XCTAssertNotNil([valueEnum nextObject]);
+ XCTAssertTrue([mutValue removeValueAndLabelAtIndex:0]);
+ XCTAssertThrows([labelEnum nextObject]);
+ XCTAssertThrows([valueEnum nextObject]);
// Test messing with the values while we're fast enumerating them
// Should throw an exception on the second access.
@@ -572,23 +589,27 @@ static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName";
// Start at one because we removed index 0 above.
count = 1;
@try {
- GTM_FOREACH_ENUMEREE(label, [mutValue labelEnumerator]) {
+ for (label in [mutValue labelEnumerator]) {
NSString *testLabel = [NSString stringWithFormat:@"label %d", count++];
- STAssertEqualObjects(label, testLabel, nil);
- STAssertTrue([mutValue removeValueAndLabelAtIndex:50], nil);
+ XCTAssertEqualObjects(label, testLabel);
+ XCTAssertTrue([mutValue removeValueAndLabelAtIndex:50]);
}
} @catch(NSException *e) {
- STAssertEqualObjects([e name], NSGenericException, @"Got %@ instead", e);
- STAssertEquals(count, 2,
+ XCTAssertEqualObjects([e name], NSGenericException, @"Got %@ instead", e);
+ XCTAssertEqual(count, 2,
@"Should have caught it on the second access");
exceptionThrown = YES;
} // COV_NF_LINE - because we always catch, this brace doesn't get exec'd
- STAssertTrue(exceptionThrown, @"We should have thrown an exception"
+ XCTAssertTrue(exceptionThrown, @"We should have thrown an exception"
@" because the values under the enumerator were modified");
}
#if GTM_IPHONE_SDK
+
+#if (!defined(__LP64__) || !__LP64__)
+// This test does not work on LP64 because refcounts are magic and don't work the
+// same as on i386.
- (void)testRadar6208390 {
GTMABPropertyType types[] = {
kGTMABStringPropertyType,
@@ -599,14 +620,10 @@ static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName";
};
for (size_t j = 0; j < sizeof(types) / sizeof(ABPropertyType); ++j) {
ABPropertyType type = types[j];
-#if GTM_IPHONE_SDK
ABMultiValueRef ref = ABMultiValueCreateMutable(type);
-#else // GTM_IPHONE_SDK
- ABMutableMultiValueRef ref = ABMultiValueCreateMutable();
-#endif // GTM_IPHONE_SDK
- STAssertNotNULL(ref, nil);
+ XCTAssertNotNULL(ref);
NSString *label = [[NSString alloc] initWithString:@"label"];
- STAssertNotNil(label, nil);
+ XCTAssertNotNil(label);
id val = nil;
if (type == kGTMABDictionaryPropertyType) {
val = [[NSDictionary alloc] initWithObjectsAndKeys:@"1", @"1", nil];
@@ -618,27 +635,26 @@ static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName";
} else if (type == kGTMABDateTimePropertyType) {
val = [[NSDate alloc] init];
}
- STAssertNotNil(val,
- @"Testing type %d, %@", type, val);
+ XCTAssertNotNil(val, @"Testing type %d, %@", type, val);
NSUInteger firstRetainCount = [val retainCount];
- STAssertNotEquals(firstRetainCount,
+ XCTAssertNotEqual(firstRetainCount,
(NSUInteger)0,
@"Testing type %d, %@", type, val);
GTMABMultiValueIdentifier identifier;
- STAssertTrue(ABMultiValueAddValueAndLabel(ref,
- val,
- (CFStringRef)label,
- &identifier),
- @"Testing type %d, %@", type, val);
+ XCTAssertTrue(ABMultiValueAddValueAndLabel(ref,
+ val,
+ (CFStringRef)label,
+ &identifier),
+ @"Testing type %d, %@", type, val);
NSUInteger secondRetainCount = [val retainCount];
- STAssertEquals(firstRetainCount + 1,
+ XCTAssertEqual(firstRetainCount + 1,
secondRetainCount,
@"Testing type %d, %@", type, val);
[label release];
[val release];
NSUInteger thirdRetainCount = [val retainCount];
- STAssertEquals(firstRetainCount,
+ XCTAssertEqual(firstRetainCount,
thirdRetainCount,
@"Testing type %d, %@", type, val);
@@ -653,13 +669,13 @@ static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName";
if (type == kGTMABIntegerPropertyType
|| type == kGTMABRealPropertyType) {
// We are verifying that yes indeed 6208390 is still broken
- STAssertEquals(fourthRetainCount,
+ XCTAssertEqual(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,
+ XCTAssertEqual(fourthRetainCount,
thirdRetainCount + 1,
@"Testing type %d, %@", type, val);
[val release];
@@ -671,6 +687,8 @@ static NSString *const kGTMABTestGroupName = @"GTMABAddressBookTestGroupName";
}
}
+#endif // (!defined(__LP64__) || !__LP64__)
+
// Globals used by testRadar6240394.
static GTMABPropertyID gGTMTestID;
static const GTMABPropertyID *gGTMTestIDPtr;
@@ -685,9 +703,9 @@ void __attribute__((constructor))SetUpIDForTestRadar6240394(void) {
// As of iPhone SDK 2.1, the property IDs aren't initialized until
// ABAddressBookCreate is actually called. They will return zero until
// then. Logged as radar 6240394.
- STAssertEquals(gGTMTestID, 0, @"If this isn't zero, Apple has fixed 6240394");
+ XCTAssertEqual(gGTMTestID, 0, @"If this isn't zero, Apple has fixed 6240394");
(void)ABAddressBookCreate();
- STAssertEquals(*gGTMTestIDPtr, kGTMABPersonLastNameProperty,
+ XCTAssertEqual(*gGTMTestIDPtr, kGTMABPersonLastNameProperty,
@"If this doesn't work, something else has broken");
}