Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(370)

Unified Diff: iPhone/GTMABAddressBookTest.m

Issue 10244: Addition of ABAddressBookCopyPeopleWithName() wrapper to GTMABAddressBook Base URL: http://google-toolbox-for-mac.googlecode.com/svn/trunk/
Patch Set: Fixed formatting to comply with Objective-C standards Created 15 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « iPhone/GTMABAddressBook.m ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: iPhone/GTMABAddressBookTest.m
===================================================================
--- iPhone/GTMABAddressBookTest.m (revision 70)
+++ iPhone/GTMABAddressBookTest.m (working copy)
@@ -500,6 +500,66 @@
}
+- (void)testPeopleWithName {
+ GTMABPerson *person1 = [GTMABPerson personWithFirstName:@"Bart"
+ lastName:@"Simpson"];
+ GTMABPerson *person2 = [GTMABPerson personWithFirstName:@"Bart"
+ lastName:nil];
+ STAssertNotNil(person1, nil);
+ STAssertNotNil(person2, nil);
+ STAssertTrue([person1 setValue:@"Mr."
+ forProperty:kABPersonPrefixProperty], nil);
+ STAssertTrue([person2 setValue:@"Mr."
+ forProperty:kABPersonPrefixProperty], nil);
+ STAssertEqualObjects([person1 compositeName], @"Mr. Bart Simpson", nil);
+ STAssertEqualObjects([person2 compositeName], @"Mr. Bart", nil);
+
+ NSArray *people = [book_ people];
+ STAssertFalse([people containsObject:person1], nil);
+ STAssertFalse([people containsObject:person2], nil);
+ STAssertTrue([book_ addRecord:person1], nil);
+ STAssertTrue([book_ addRecord:person2], nil);
+ STAssertTrue([book_ save], nil);
+
+ people = [book_ people];
+ STAssertTrue([people containsObject:person1], nil);
+ STAssertTrue([people containsObject:person2], nil);
+
+ NSArray *matched = [book_ peopleWithName:@"WrongName"];
+ int count = [matched count];
+ STAssertNotNil(matched, nil);
+ STAssertEquals(count, 0, nil);
+
+ // This really should match both contacts, but because of
+ // Radar 6425729: ABAddressBookCopyPeopleWithName() does not
+ // correctly match by composite name
+ // it doesn't match either of them (because of the prefix)
+ matched = [book_ peopleWithName:@"Mr. Bart*"];
+ count = [matched count];
+ STAssertNotNil(matched, nil);
+ STAssertEquals(count, 0, nil);
+ STAssertFalse([matched containsObject:person1], nil);
+ STAssertFalse([matched containsObject:person2], nil);
+
+ matched = [book_ peopleWithName:@"Bart*"];
+ count = [matched count];
+ STAssertNotNil(matched, nil);
+ STAssertEquals(count, 2, nil);
+ STAssertTrue([matched containsObject:person1], nil);
+ STAssertTrue([matched containsObject:person2], nil);
+
+ matched = [book_ peopleWithName:@"Bart Simpson"];
+ count = [matched count];
+ STAssertNotNil(matched, nil);
+ STAssertEquals(count, 1, nil);
+ STAssertTrue([matched containsObject:person1], nil);
+ STAssertFalse([matched containsObject:person2], nil);
+
+ STAssertTrue([book_ removeRecord:person1], nil);
+ STAssertTrue([book_ removeRecord:person2], nil);
+ STAssertTrue([book_ save], nil);
+}
+
- (void)testRadar6208390 {
ABPropertyType types[] = {
kABStringPropertyType,
« no previous file with comments | « iPhone/GTMABAddressBook.m ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b