diff options
author | Jisi Liu <jisi.liu@gmail.com> | 2015-10-05 13:54:05 -0700 |
---|---|---|
committer | Jisi Liu <jisi.liu@gmail.com> | 2015-10-05 13:54:05 -0700 |
commit | 8d8177c75701014dfe27fec4cdd2b1647aefcb67 (patch) | |
tree | fdc5d0d0f2fd57f2ca641069c20b34ddf90ec919 /objectivec/Tests | |
parent | 46e8ff63cb67a6520711da5317aaaef04d0414d0 (diff) | |
parent | cccf6fed7e2fad1240bb48ba0c47f3978ff7433d (diff) | |
download | protobuf-8d8177c75701014dfe27fec4cdd2b1647aefcb67.tar.gz protobuf-8d8177c75701014dfe27fec4cdd2b1647aefcb67.tar.bz2 protobuf-8d8177c75701014dfe27fec4cdd2b1647aefcb67.zip |
Merge remote-tracking branch 'origin/master' into fix-author
Diffstat (limited to 'objectivec/Tests')
-rw-r--r-- | objectivec/Tests/GPBDictionaryTests+Bool.m | 200 | ||||
-rw-r--r-- | objectivec/Tests/GPBDictionaryTests+Int32.m | 254 | ||||
-rw-r--r-- | objectivec/Tests/GPBDictionaryTests+Int64.m | 254 | ||||
-rw-r--r-- | objectivec/Tests/GPBDictionaryTests+String.m | 36 | ||||
-rw-r--r-- | objectivec/Tests/GPBDictionaryTests+UInt32.m | 254 | ||||
-rw-r--r-- | objectivec/Tests/GPBDictionaryTests+UInt64.m | 254 | ||||
-rw-r--r-- | objectivec/Tests/GPBDictionaryTests.pddm | 376 | ||||
-rw-r--r-- | objectivec/Tests/GPBMessageTests+Merge.m | 7 | ||||
-rw-r--r-- | objectivec/Tests/GPBMessageTests+Runtime.m | 6 | ||||
-rw-r--r-- | objectivec/Tests/GPBMessageTests+Serialization.m | 8 | ||||
-rw-r--r-- | objectivec/Tests/GPBObjectiveCPlusPlusTest.mm | 69 | ||||
-rw-r--r-- | objectivec/Tests/GPBTestUtilities.m | 4 | ||||
-rw-r--r-- | objectivec/Tests/GPBWireFormatTests.m | 4 |
13 files changed, 898 insertions, 828 deletions
diff --git a/objectivec/Tests/GPBDictionaryTests+Bool.m b/objectivec/Tests/GPBDictionaryTests+Bool.m index 43650f51..8b1900fe 100644 --- a/objectivec/Tests/GPBDictionaryTests+Bool.m +++ b/objectivec/Tests/GPBDictionaryTests+Bool.m @@ -167,10 +167,10 @@ // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 Fewer pairs; not equal @@ -468,10 +468,10 @@ // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 Fewer pairs; not equal @@ -769,10 +769,10 @@ // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 Fewer pairs; not equal @@ -1070,10 +1070,10 @@ // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 Fewer pairs; not equal @@ -1371,10 +1371,10 @@ // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 Fewer pairs; not equal @@ -1672,10 +1672,10 @@ // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 Fewer pairs; not equal @@ -1973,10 +1973,10 @@ // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 Fewer pairs; not equal @@ -2161,46 +2161,46 @@ GPBBoolObjectDictionary *dict = [[GPBBoolObjectDictionary alloc] init]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:YES]); - [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue, stop) + XCTAssertNil([dict objectForKey:YES]); + [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject, stop) XCTFail(@"Shouldn't get here!"); }]; [dict release]; } - (void)testOne { - GPBBoolObjectDictionary *dict = [GPBBoolObjectDictionary dictionaryWithValue:@"abc" forKey:YES]; + GPBBoolObjectDictionary *dict = [GPBBoolObjectDictionary dictionaryWithObject:@"abc" forKey:YES]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 1U); - XCTAssertEqualObjects([dict valueForKey:YES], @"abc"); - XCTAssertNil([dict valueForKey:NO]); - [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, id aValue, BOOL *stop) { + XCTAssertEqualObjects([dict objectForKey:YES], @"abc"); + XCTAssertNil([dict objectForKey:NO]); + [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) { XCTAssertEqual(aKey, YES); - XCTAssertEqualObjects(aValue, @"abc"); + XCTAssertEqualObjects(aObject, @"abc"); XCTAssertNotEqual(stop, NULL); }]; } - (void)testBasics { const BOOL kKeys[] = { YES, NO }; - const id kValues[] = { @"abc", @"def" }; + const id kObjects[] = { @"abc", @"def" }; GPBBoolObjectDictionary *dict = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:YES], @"abc"); - XCTAssertEqualObjects([dict valueForKey:NO], @"def"); + XCTAssertEqualObjects([dict objectForKey:YES], @"abc"); + XCTAssertEqualObjects([dict objectForKey:NO], @"def"); __block NSUInteger idx = 0; BOOL *seenKeys = malloc(2 * sizeof(BOOL)); - id *seenValues = malloc(2 * sizeof(id)); - [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, id aValue, BOOL *stop) { + id *seenObjects = malloc(2 * sizeof(id)); + [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) { XCTAssertLessThan(idx, 2U); seenKeys[idx] = aKey; - seenValues[idx] = aValue; + seenObjects[idx] = aObject; XCTAssertNotEqual(stop, NULL); ++idx; }]; @@ -2209,18 +2209,18 @@ for (int j = 0; (j < 2) && !foundKey; ++j) { if (kKeys[i] == seenKeys[j]) { foundKey = YES; - XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); + XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j); } } XCTAssertTrue(foundKey, @"i = %d", i); } free(seenKeys); - free(seenValues); + free(seenObjects); // Stopping the enumeration. idx = 0; - [dict enumerateKeysAndValuesUsingBlock:^(BOOL aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue) + [dict enumerateKeysAndObjectsUsingBlock:^(BOOL aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject) if (idx == 0) *stop = YES; XCTAssertNotEqual(idx, 2U); ++idx; @@ -2231,33 +2231,33 @@ - (void)testEquality { const BOOL kKeys1[] = { YES, NO }; const BOOL kKeys2[] = { NO, YES }; - const id kValues1[] = { @"abc", @"def" }; - const id kValues2[] = { @"def", @"abc" }; - const id kValues3[] = { @"def" }; + const id kObjects1[] = { @"abc", @"def" }; + const id kObjects2[] = { @"def", @"abc" }; + const id kObjects3[] = { @"def" }; GPBBoolObjectDictionary *dict1 = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1); GPBBoolObjectDictionary *dict1prime = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1prime); GPBBoolObjectDictionary *dict2 = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues2)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); GPBBoolObjectDictionary *dict3 = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues1)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict3); GPBBoolObjectDictionary *dict4 = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues3 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues3)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects3 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects3)]; XCTAssertNotNil(dict4); // 1/1Prime should be different objects, but equal. @@ -2266,10 +2266,10 @@ // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different objects; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same objects; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 Fewer pairs; not equal @@ -2284,11 +2284,11 @@ - (void)testCopy { const BOOL kKeys[] = { YES, NO }; - const id kValues[] = { @"abc", @"def" }; + const id kObjects[] = { @"abc", @"def" }; GPBBoolObjectDictionary *dict = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBBoolObjectDictionary *dict2 = [dict copy]; @@ -2305,11 +2305,11 @@ - (void)testDictionaryFromDictionary { const BOOL kKeys[] = { YES, NO }; - const id kValues[] = { @"abc", @"def" }; + const id kObjects[] = { @"abc", @"def" }; GPBBoolObjectDictionary *dict = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBBoolObjectDictionary *dict2 = @@ -2327,85 +2327,85 @@ XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - [dict setValue:@"abc" forKey:YES]; + [dict setObject:@"abc" forKey:YES]; XCTAssertEqual(dict.count, 1U); const BOOL kKeys[] = { NO }; - const id kValues[] = { @"def" }; + const id kObjects[] = { @"def" }; GPBBoolObjectDictionary *dict2 = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:YES], @"abc"); - XCTAssertEqualObjects([dict valueForKey:NO], @"def"); + XCTAssertEqualObjects([dict objectForKey:YES], @"abc"); + XCTAssertEqualObjects([dict objectForKey:NO], @"def"); [dict2 release]; } - (void)testRemove { const BOOL kKeys[] = { YES, NO}; - const id kValues[] = { @"abc", @"def" }; + const id kObjects[] = { @"abc", @"def" }; GPBBoolObjectDictionary *dict = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 2U); - [dict removeValueForKey:NO]; + [dict removeObjectForKey:NO]; XCTAssertEqual(dict.count, 1U); - XCTAssertEqualObjects([dict valueForKey:YES], @"abc"); - XCTAssertNil([dict valueForKey:NO]); + XCTAssertEqualObjects([dict objectForKey:YES], @"abc"); + XCTAssertNil([dict objectForKey:NO]); // Remove again does nothing. - [dict removeValueForKey:NO]; + [dict removeObjectForKey:NO]; XCTAssertEqual(dict.count, 1U); - XCTAssertEqualObjects([dict valueForKey:YES], @"abc"); - XCTAssertNil([dict valueForKey:NO]); + XCTAssertEqualObjects([dict objectForKey:YES], @"abc"); + XCTAssertNil([dict objectForKey:NO]); [dict removeAll]; XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:YES]); - XCTAssertNil([dict valueForKey:NO]); + XCTAssertNil([dict objectForKey:YES]); + XCTAssertNil([dict objectForKey:NO]); [dict release]; } - (void)testInplaceMutation { const BOOL kKeys[] = { YES, NO }; - const id kValues[] = { @"abc", @"def" }; + const id kObjects[] = { @"abc", @"def" }; GPBBoolObjectDictionary *dict = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:YES], @"abc"); - XCTAssertEqualObjects([dict valueForKey:NO], @"def"); + XCTAssertEqualObjects([dict objectForKey:YES], @"abc"); + XCTAssertEqualObjects([dict objectForKey:NO], @"def"); - [dict setValue:@"def" forKey:YES]; + [dict setObject:@"def" forKey:YES]; XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:YES], @"def"); - XCTAssertEqualObjects([dict valueForKey:NO], @"def"); + XCTAssertEqualObjects([dict objectForKey:YES], @"def"); + XCTAssertEqualObjects([dict objectForKey:NO], @"def"); - [dict setValue:@"abc" forKey:NO]; + [dict setObject:@"abc" forKey:NO]; XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:YES], @"def"); - XCTAssertEqualObjects([dict valueForKey:NO], @"abc"); + XCTAssertEqualObjects([dict objectForKey:YES], @"def"); + XCTAssertEqualObjects([dict objectForKey:NO], @"abc"); const BOOL kKeys2[] = { NO, YES }; - const id kValues2[] = { @"def", @"abc" }; + const id kObjects2[] = { @"def", @"abc" }; GPBBoolObjectDictionary *dict2 = - [[GPBBoolObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues2)]; + [[GPBBoolObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:YES], @"abc"); - XCTAssertEqualObjects([dict valueForKey:NO], @"def"); + XCTAssertEqualObjects([dict objectForKey:YES], @"abc"); + XCTAssertEqualObjects([dict objectForKey:NO], @"def"); [dict2 release]; [dict release]; diff --git a/objectivec/Tests/GPBDictionaryTests+Int32.m b/objectivec/Tests/GPBDictionaryTests+Int32.m index 1ee099ee..21d3f07d 100644 --- a/objectivec/Tests/GPBDictionaryTests+Int32.m +++ b/objectivec/Tests/GPBDictionaryTests+Int32.m @@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3366,48 +3366,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { GPBInt32ObjectDictionary *dict = [[GPBInt32ObjectDictionary alloc] init]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:11]); - [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue, stop) + XCTAssertNil([dict objectForKey:11]); + [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject, stop) XCTFail(@"Shouldn't get here!"); }]; [dict release]; } - (void)testOne { - GPBInt32ObjectDictionary *dict = [GPBInt32ObjectDictionary dictionaryWithValue:@"abc" forKey:11]; + GPBInt32ObjectDictionary *dict = [GPBInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:11]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 1U); - XCTAssertEqualObjects([dict valueForKey:11], @"abc"); - XCTAssertNil([dict valueForKey:12]); - [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, id aValue, BOOL *stop) { + XCTAssertEqualObjects([dict objectForKey:11], @"abc"); + XCTAssertNil([dict objectForKey:12]); + [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) { XCTAssertEqual(aKey, 11); - XCTAssertEqualObjects(aValue, @"abc"); + XCTAssertEqualObjects(aObject, @"abc"); XCTAssertNotEqual(stop, NULL); }]; } - (void)testBasics { const int32_t kKeys[] = { 11, 12, 13 }; - const id kValues[] = { @"abc", @"def", @"ghi" }; + const id kObjects[] = { @"abc", @"def", @"ghi" }; GPBInt32ObjectDictionary *dict = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:11], @"abc"); - XCTAssertEqualObjects([dict valueForKey:12], @"def"); - XCTAssertEqualObjects([dict valueForKey:13], @"ghi"); - XCTAssertNil([dict valueForKey:14]); + XCTAssertEqualObjects([dict objectForKey:11], @"abc"); + XCTAssertEqualObjects([dict objectForKey:12], @"def"); + XCTAssertEqualObjects([dict objectForKey:13], @"ghi"); + XCTAssertNil([dict objectForKey:14]); __block NSUInteger idx = 0; int32_t *seenKeys = malloc(3 * sizeof(int32_t)); - id *seenValues = malloc(3 * sizeof(id)); - [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, id aValue, BOOL *stop) { + id *seenObjects = malloc(3 * sizeof(id)); + [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) { XCTAssertLessThan(idx, 3U); seenKeys[idx] = aKey; - seenValues[idx] = aValue; + seenObjects[idx] = aObject; XCTAssertNotEqual(stop, NULL); ++idx; }]; @@ -3416,18 +3416,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { for (int j = 0; (j < 3) && !foundKey; ++j) { if (kKeys[i] == seenKeys[j]) { foundKey = YES; - XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); + XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j); } } XCTAssertTrue(foundKey, @"i = %d", i); } free(seenKeys); - free(seenValues); + free(seenObjects); // Stopping the enumeration. idx = 0; - [dict enumerateKeysAndValuesUsingBlock:^(int32_t aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue) + [dict enumerateKeysAndObjectsUsingBlock:^(int32_t aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject) if (idx == 1) *stop = YES; XCTAssertNotEqual(idx, 2U); ++idx; @@ -3438,33 +3438,33 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testEquality { const int32_t kKeys1[] = { 11, 12, 13, 14 }; const int32_t kKeys2[] = { 12, 11, 14 }; - const id kValues1[] = { @"abc", @"def", @"ghi" }; - const id kValues2[] = { @"abc", @"jkl", @"ghi" }; - const id kValues3[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects1[] = { @"abc", @"def", @"ghi" }; + const id kObjects2[] = { @"abc", @"jkl", @"ghi" }; + const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt32ObjectDictionary *dict1 = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1); GPBInt32ObjectDictionary *dict1prime = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1prime); GPBInt32ObjectDictionary *dict2 = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues2)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); GPBInt32ObjectDictionary *dict3 = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues1)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict3); GPBInt32ObjectDictionary *dict4 = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues3 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues3)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects3 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects3)]; XCTAssertNotNil(dict4); // 1/1Prime should be different objects, but equal. @@ -3473,10 +3473,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different objects; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same objects; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3491,11 +3491,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testCopy { const int32_t kKeys[] = { 11, 12, 13, 14 }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt32ObjectDictionary *dict = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBInt32ObjectDictionary *dict2 = [dict copy]; @@ -3512,11 +3512,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testDictionaryFromDictionary { const int32_t kKeys[] = { 11, 12, 13, 14 }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt32ObjectDictionary *dict = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBInt32ObjectDictionary *dict2 = @@ -3534,108 +3534,108 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - [dict setValue:@"abc" forKey:11]; + [dict setObject:@"abc" forKey:11]; XCTAssertEqual(dict.count, 1U); const int32_t kKeys[] = { 12, 13, 14 }; - const id kValues[] = { @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"def", @"ghi", @"jkl" }; GPBInt32ObjectDictionary *dict2 = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:11], @"abc"); - XCTAssertEqualObjects([dict valueForKey:12], @"def"); - XCTAssertEqualObjects([dict valueForKey:13], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:14], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:11], @"abc"); + XCTAssertEqualObjects([dict objectForKey:12], @"def"); + XCTAssertEqualObjects([dict objectForKey:13], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:14], @"jkl"); [dict2 release]; } - (void)testRemove { const int32_t kKeys[] = { 11, 12, 13, 14 }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt32ObjectDictionary *dict = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 4U); - [dict removeValueForKey:12]; + [dict removeObjectForKey:12]; XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:11], @"abc"); - XCTAssertNil([dict valueForKey:12]); - XCTAssertEqualObjects([dict valueForKey:13], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:14], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:11], @"abc"); + XCTAssertNil([dict objectForKey:12]); + XCTAssertEqualObjects([dict objectForKey:13], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:14], @"jkl"); // Remove again does nothing. - [dict removeValueForKey:12]; + [dict removeObjectForKey:12]; XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:11], @"abc"); - XCTAssertNil([dict valueForKey:12]); - XCTAssertEqualObjects([dict valueForKey:13], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:14], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:11], @"abc"); + XCTAssertNil([dict objectForKey:12]); + XCTAssertEqualObjects([dict objectForKey:13], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:14], @"jkl"); - [dict removeValueForKey:14]; + [dict removeObjectForKey:14]; XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:11], @"abc"); - XCTAssertNil([dict valueForKey:12]); - XCTAssertEqualObjects([dict valueForKey:13], @"ghi"); - XCTAssertNil([dict valueForKey:14]); + XCTAssertEqualObjects([dict objectForKey:11], @"abc"); + XCTAssertNil([dict objectForKey:12]); + XCTAssertEqualObjects([dict objectForKey:13], @"ghi"); + XCTAssertNil([dict objectForKey:14]); [dict removeAll]; XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:11]); - XCTAssertNil([dict valueForKey:12]); - XCTAssertNil([dict valueForKey:13]); - XCTAssertNil([dict valueForKey:14]); + XCTAssertNil([dict objectForKey:11]); + XCTAssertNil([dict objectForKey:12]); + XCTAssertNil([dict objectForKey:13]); + XCTAssertNil([dict objectForKey:14]); [dict release]; } - (void)testInplaceMutation { const int32_t kKeys[] = { 11, 12, 13, 14 }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt32ObjectDictionary *dict = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:11], @"abc"); - XCTAssertEqualObjects([dict valueForKey:12], @"def"); - XCTAssertEqualObjects([dict valueForKey:13], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:14], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:11], @"abc"); + XCTAssertEqualObjects([dict objectForKey:12], @"def"); + XCTAssertEqualObjects([dict objectForKey:13], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:14], @"jkl"); - [dict setValue:@"jkl" forKey:11]; + [dict setObject:@"jkl" forKey:11]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:11], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:12], @"def"); - XCTAssertEqualObjects([dict valueForKey:13], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:14], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:11], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:12], @"def"); + XCTAssertEqualObjects([dict objectForKey:13], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:14], @"jkl"); - [dict setValue:@"def" forKey:14]; + [dict setObject:@"def" forKey:14]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:11], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:12], @"def"); - XCTAssertEqualObjects([dict valueForKey:13], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:14], @"def"); + XCTAssertEqualObjects([dict objectForKey:11], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:12], @"def"); + XCTAssertEqualObjects([dict objectForKey:13], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:14], @"def"); const int32_t kKeys2[] = { 12, 13 }; - const id kValues2[] = { @"ghi", @"abc" }; + const id kObjects2[] = { @"ghi", @"abc" }; GPBInt32ObjectDictionary *dict2 = - [[GPBInt32ObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues2)]; + [[GPBInt32ObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:11], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:12], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:13], @"abc"); - XCTAssertEqualObjects([dict valueForKey:14], @"def"); + XCTAssertEqualObjects([dict objectForKey:11], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:12], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:13], @"abc"); + XCTAssertEqualObjects([dict objectForKey:14], @"def"); [dict2 release]; [dict release]; diff --git a/objectivec/Tests/GPBDictionaryTests+Int64.m b/objectivec/Tests/GPBDictionaryTests+Int64.m index 4a94e033..27f77f28 100644 --- a/objectivec/Tests/GPBDictionaryTests+Int64.m +++ b/objectivec/Tests/GPBDictionaryTests+Int64.m @@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3366,48 +3366,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { GPBInt64ObjectDictionary *dict = [[GPBInt64ObjectDictionary alloc] init]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:21LL]); - [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue, stop) + XCTAssertNil([dict objectForKey:21LL]); + [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject, stop) XCTFail(@"Shouldn't get here!"); }]; [dict release]; } - (void)testOne { - GPBInt64ObjectDictionary *dict = [GPBInt64ObjectDictionary dictionaryWithValue:@"abc" forKey:21LL]; + GPBInt64ObjectDictionary *dict = [GPBInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:21LL]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 1U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"abc"); - XCTAssertNil([dict valueForKey:22LL]); - [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, id aValue, BOOL *stop) { + XCTAssertEqualObjects([dict objectForKey:21LL], @"abc"); + XCTAssertNil([dict objectForKey:22LL]); + [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) { XCTAssertEqual(aKey, 21LL); - XCTAssertEqualObjects(aValue, @"abc"); + XCTAssertEqualObjects(aObject, @"abc"); XCTAssertNotEqual(stop, NULL); }]; } - (void)testBasics { const int64_t kKeys[] = { 21LL, 22LL, 23LL }; - const id kValues[] = { @"abc", @"def", @"ghi" }; + const id kObjects[] = { @"abc", @"def", @"ghi" }; GPBInt64ObjectDictionary *dict = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"abc"); - XCTAssertEqualObjects([dict valueForKey:22LL], @"def"); - XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi"); - XCTAssertNil([dict valueForKey:24LL]); + XCTAssertEqualObjects([dict objectForKey:21LL], @"abc"); + XCTAssertEqualObjects([dict objectForKey:22LL], @"def"); + XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi"); + XCTAssertNil([dict objectForKey:24LL]); __block NSUInteger idx = 0; int64_t *seenKeys = malloc(3 * sizeof(int64_t)); - id *seenValues = malloc(3 * sizeof(id)); - [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, id aValue, BOOL *stop) { + id *seenObjects = malloc(3 * sizeof(id)); + [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) { XCTAssertLessThan(idx, 3U); seenKeys[idx] = aKey; - seenValues[idx] = aValue; + seenObjects[idx] = aObject; XCTAssertNotEqual(stop, NULL); ++idx; }]; @@ -3416,18 +3416,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { for (int j = 0; (j < 3) && !foundKey; ++j) { if (kKeys[i] == seenKeys[j]) { foundKey = YES; - XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); + XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j); } } XCTAssertTrue(foundKey, @"i = %d", i); } free(seenKeys); - free(seenValues); + free(seenObjects); // Stopping the enumeration. idx = 0; - [dict enumerateKeysAndValuesUsingBlock:^(int64_t aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue) + [dict enumerateKeysAndObjectsUsingBlock:^(int64_t aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject) if (idx == 1) *stop = YES; XCTAssertNotEqual(idx, 2U); ++idx; @@ -3438,33 +3438,33 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testEquality { const int64_t kKeys1[] = { 21LL, 22LL, 23LL, 24LL }; const int64_t kKeys2[] = { 22LL, 21LL, 24LL }; - const id kValues1[] = { @"abc", @"def", @"ghi" }; - const id kValues2[] = { @"abc", @"jkl", @"ghi" }; - const id kValues3[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects1[] = { @"abc", @"def", @"ghi" }; + const id kObjects2[] = { @"abc", @"jkl", @"ghi" }; + const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt64ObjectDictionary *dict1 = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1); GPBInt64ObjectDictionary *dict1prime = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1prime); GPBInt64ObjectDictionary *dict2 = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues2)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); GPBInt64ObjectDictionary *dict3 = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues1)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict3); GPBInt64ObjectDictionary *dict4 = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues3 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues3)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects3 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects3)]; XCTAssertNotNil(dict4); // 1/1Prime should be different objects, but equal. @@ -3473,10 +3473,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different objects; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same objects; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3491,11 +3491,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testCopy { const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt64ObjectDictionary *dict = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBInt64ObjectDictionary *dict2 = [dict copy]; @@ -3512,11 +3512,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testDictionaryFromDictionary { const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt64ObjectDictionary *dict = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBInt64ObjectDictionary *dict2 = @@ -3534,108 +3534,108 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - [dict setValue:@"abc" forKey:21LL]; + [dict setObject:@"abc" forKey:21LL]; XCTAssertEqual(dict.count, 1U); const int64_t kKeys[] = { 22LL, 23LL, 24LL }; - const id kValues[] = { @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"def", @"ghi", @"jkl" }; GPBInt64ObjectDictionary *dict2 = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"abc"); - XCTAssertEqualObjects([dict valueForKey:22LL], @"def"); - XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:21LL], @"abc"); + XCTAssertEqualObjects([dict objectForKey:22LL], @"def"); + XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl"); [dict2 release]; } - (void)testRemove { const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt64ObjectDictionary *dict = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 4U); - [dict removeValueForKey:22LL]; + [dict removeObjectForKey:22LL]; XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"abc"); - XCTAssertNil([dict valueForKey:22LL]); - XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:21LL], @"abc"); + XCTAssertNil([dict objectForKey:22LL]); + XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl"); // Remove again does nothing. - [dict removeValueForKey:22LL]; + [dict removeObjectForKey:22LL]; XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"abc"); - XCTAssertNil([dict valueForKey:22LL]); - XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:21LL], @"abc"); + XCTAssertNil([dict objectForKey:22LL]); + XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl"); - [dict removeValueForKey:24LL]; + [dict removeObjectForKey:24LL]; XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"abc"); - XCTAssertNil([dict valueForKey:22LL]); - XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi"); - XCTAssertNil([dict valueForKey:24LL]); + XCTAssertEqualObjects([dict objectForKey:21LL], @"abc"); + XCTAssertNil([dict objectForKey:22LL]); + XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi"); + XCTAssertNil([dict objectForKey:24LL]); [dict removeAll]; XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:21LL]); - XCTAssertNil([dict valueForKey:22LL]); - XCTAssertNil([dict valueForKey:23LL]); - XCTAssertNil([dict valueForKey:24LL]); + XCTAssertNil([dict objectForKey:21LL]); + XCTAssertNil([dict objectForKey:22LL]); + XCTAssertNil([dict objectForKey:23LL]); + XCTAssertNil([dict objectForKey:24LL]); [dict release]; } - (void)testInplaceMutation { const int64_t kKeys[] = { 21LL, 22LL, 23LL, 24LL }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBInt64ObjectDictionary *dict = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"abc"); - XCTAssertEqualObjects([dict valueForKey:22LL], @"def"); - XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:21LL], @"abc"); + XCTAssertEqualObjects([dict objectForKey:22LL], @"def"); + XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl"); - [dict setValue:@"jkl" forKey:21LL]; + [dict setObject:@"jkl" forKey:21LL]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:22LL], @"def"); - XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:24LL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:21LL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:22LL], @"def"); + XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl"); - [dict setValue:@"def" forKey:24LL]; + [dict setObject:@"def" forKey:24LL]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:22LL], @"def"); - XCTAssertEqualObjects([dict valueForKey:23LL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:24LL], @"def"); + XCTAssertEqualObjects([dict objectForKey:21LL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:22LL], @"def"); + XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:24LL], @"def"); const int64_t kKeys2[] = { 22LL, 23LL }; - const id kValues2[] = { @"ghi", @"abc" }; + const id kObjects2[] = { @"ghi", @"abc" }; GPBInt64ObjectDictionary *dict2 = - [[GPBInt64ObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues2)]; + [[GPBInt64ObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:21LL], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:22LL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:23LL], @"abc"); - XCTAssertEqualObjects([dict valueForKey:24LL], @"def"); + XCTAssertEqualObjects([dict objectForKey:21LL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:22LL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:23LL], @"abc"); + XCTAssertEqualObjects([dict objectForKey:24LL], @"def"); [dict2 release]; [dict release]; diff --git a/objectivec/Tests/GPBDictionaryTests+String.m b/objectivec/Tests/GPBDictionaryTests+String.m index 09fbc608..bfa10b19 100644 --- a/objectivec/Tests/GPBDictionaryTests+String.m +++ b/objectivec/Tests/GPBDictionaryTests+String.m @@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal diff --git a/objectivec/Tests/GPBDictionaryTests+UInt32.m b/objectivec/Tests/GPBDictionaryTests+UInt32.m index f8d280fa..c7c57652 100644 --- a/objectivec/Tests/GPBDictionaryTests+UInt32.m +++ b/objectivec/Tests/GPBDictionaryTests+UInt32.m @@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3366,48 +3366,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { GPBUInt32ObjectDictionary *dict = [[GPBUInt32ObjectDictionary alloc] init]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:1U]); - [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue, stop) + XCTAssertNil([dict objectForKey:1U]); + [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject, stop) XCTFail(@"Shouldn't get here!"); }]; [dict release]; } - (void)testOne { - GPBUInt32ObjectDictionary *dict = [GPBUInt32ObjectDictionary dictionaryWithValue:@"abc" forKey:1U]; + GPBUInt32ObjectDictionary *dict = [GPBUInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:1U]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 1U); - XCTAssertEqualObjects([dict valueForKey:1U], @"abc"); - XCTAssertNil([dict valueForKey:2U]); - [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, id aValue, BOOL *stop) { + XCTAssertEqualObjects([dict objectForKey:1U], @"abc"); + XCTAssertNil([dict objectForKey:2U]); + [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) { XCTAssertEqual(aKey, 1U); - XCTAssertEqualObjects(aValue, @"abc"); + XCTAssertEqualObjects(aObject, @"abc"); XCTAssertNotEqual(stop, NULL); }]; } - (void)testBasics { const uint32_t kKeys[] = { 1U, 2U, 3U }; - const id kValues[] = { @"abc", @"def", @"ghi" }; + const id kObjects[] = { @"abc", @"def", @"ghi" }; GPBUInt32ObjectDictionary *dict = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:1U], @"abc"); - XCTAssertEqualObjects([dict valueForKey:2U], @"def"); - XCTAssertEqualObjects([dict valueForKey:3U], @"ghi"); - XCTAssertNil([dict valueForKey:4U]); + XCTAssertEqualObjects([dict objectForKey:1U], @"abc"); + XCTAssertEqualObjects([dict objectForKey:2U], @"def"); + XCTAssertEqualObjects([dict objectForKey:3U], @"ghi"); + XCTAssertNil([dict objectForKey:4U]); __block NSUInteger idx = 0; uint32_t *seenKeys = malloc(3 * sizeof(uint32_t)); - id *seenValues = malloc(3 * sizeof(id)); - [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, id aValue, BOOL *stop) { + id *seenObjects = malloc(3 * sizeof(id)); + [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) { XCTAssertLessThan(idx, 3U); seenKeys[idx] = aKey; - seenValues[idx] = aValue; + seenObjects[idx] = aObject; XCTAssertNotEqual(stop, NULL); ++idx; }]; @@ -3416,18 +3416,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { for (int j = 0; (j < 3) && !foundKey; ++j) { if (kKeys[i] == seenKeys[j]) { foundKey = YES; - XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); + XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j); } } XCTAssertTrue(foundKey, @"i = %d", i); } free(seenKeys); - free(seenValues); + free(seenObjects); // Stopping the enumeration. idx = 0; - [dict enumerateKeysAndValuesUsingBlock:^(uint32_t aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue) + [dict enumerateKeysAndObjectsUsingBlock:^(uint32_t aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject) if (idx == 1) *stop = YES; XCTAssertNotEqual(idx, 2U); ++idx; @@ -3438,33 +3438,33 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testEquality { const uint32_t kKeys1[] = { 1U, 2U, 3U, 4U }; const uint32_t kKeys2[] = { 2U, 1U, 4U }; - const id kValues1[] = { @"abc", @"def", @"ghi" }; - const id kValues2[] = { @"abc", @"jkl", @"ghi" }; - const id kValues3[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects1[] = { @"abc", @"def", @"ghi" }; + const id kObjects2[] = { @"abc", @"jkl", @"ghi" }; + const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt32ObjectDictionary *dict1 = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1); GPBUInt32ObjectDictionary *dict1prime = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1prime); GPBUInt32ObjectDictionary *dict2 = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues2)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); GPBUInt32ObjectDictionary *dict3 = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues1)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict3); GPBUInt32ObjectDictionary *dict4 = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues3 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues3)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects3 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects3)]; XCTAssertNotNil(dict4); // 1/1Prime should be different objects, but equal. @@ -3473,10 +3473,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different objects; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same objects; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3491,11 +3491,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testCopy { const uint32_t kKeys[] = { 1U, 2U, 3U, 4U }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt32ObjectDictionary *dict = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBUInt32ObjectDictionary *dict2 = [dict copy]; @@ -3512,11 +3512,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testDictionaryFromDictionary { const uint32_t kKeys[] = { 1U, 2U, 3U, 4U }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt32ObjectDictionary *dict = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBUInt32ObjectDictionary *dict2 = @@ -3534,108 +3534,108 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - [dict setValue:@"abc" forKey:1U]; + [dict setObject:@"abc" forKey:1U]; XCTAssertEqual(dict.count, 1U); const uint32_t kKeys[] = { 2U, 3U, 4U }; - const id kValues[] = { @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"def", @"ghi", @"jkl" }; GPBUInt32ObjectDictionary *dict2 = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:1U], @"abc"); - XCTAssertEqualObjects([dict valueForKey:2U], @"def"); - XCTAssertEqualObjects([dict valueForKey:3U], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:4U], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:1U], @"abc"); + XCTAssertEqualObjects([dict objectForKey:2U], @"def"); + XCTAssertEqualObjects([dict objectForKey:3U], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:4U], @"jkl"); [dict2 release]; } - (void)testRemove { const uint32_t kKeys[] = { 1U, 2U, 3U, 4U }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt32ObjectDictionary *dict = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 4U); - [dict removeValueForKey:2U]; + [dict removeObjectForKey:2U]; XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:1U], @"abc"); - XCTAssertNil([dict valueForKey:2U]); - XCTAssertEqualObjects([dict valueForKey:3U], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:4U], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:1U], @"abc"); + XCTAssertNil([dict objectForKey:2U]); + XCTAssertEqualObjects([dict objectForKey:3U], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:4U], @"jkl"); // Remove again does nothing. - [dict removeValueForKey:2U]; + [dict removeObjectForKey:2U]; XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:1U], @"abc"); - XCTAssertNil([dict valueForKey:2U]); - XCTAssertEqualObjects([dict valueForKey:3U], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:4U], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:1U], @"abc"); + XCTAssertNil([dict objectForKey:2U]); + XCTAssertEqualObjects([dict objectForKey:3U], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:4U], @"jkl"); - [dict removeValueForKey:4U]; + [dict removeObjectForKey:4U]; XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:1U], @"abc"); - XCTAssertNil([dict valueForKey:2U]); - XCTAssertEqualObjects([dict valueForKey:3U], @"ghi"); - XCTAssertNil([dict valueForKey:4U]); + XCTAssertEqualObjects([dict objectForKey:1U], @"abc"); + XCTAssertNil([dict objectForKey:2U]); + XCTAssertEqualObjects([dict objectForKey:3U], @"ghi"); + XCTAssertNil([dict objectForKey:4U]); [dict removeAll]; XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:1U]); - XCTAssertNil([dict valueForKey:2U]); - XCTAssertNil([dict valueForKey:3U]); - XCTAssertNil([dict valueForKey:4U]); + XCTAssertNil([dict objectForKey:1U]); + XCTAssertNil([dict objectForKey:2U]); + XCTAssertNil([dict objectForKey:3U]); + XCTAssertNil([dict objectForKey:4U]); [dict release]; } - (void)testInplaceMutation { const uint32_t kKeys[] = { 1U, 2U, 3U, 4U }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt32ObjectDictionary *dict = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:1U], @"abc"); - XCTAssertEqualObjects([dict valueForKey:2U], @"def"); - XCTAssertEqualObjects([dict valueForKey:3U], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:4U], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:1U], @"abc"); + XCTAssertEqualObjects([dict objectForKey:2U], @"def"); + XCTAssertEqualObjects([dict objectForKey:3U], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:4U], @"jkl"); - [dict setValue:@"jkl" forKey:1U]; + [dict setObject:@"jkl" forKey:1U]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:1U], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:2U], @"def"); - XCTAssertEqualObjects([dict valueForKey:3U], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:4U], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:1U], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:2U], @"def"); + XCTAssertEqualObjects([dict objectForKey:3U], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:4U], @"jkl"); - [dict setValue:@"def" forKey:4U]; + [dict setObject:@"def" forKey:4U]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:1U], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:2U], @"def"); - XCTAssertEqualObjects([dict valueForKey:3U], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:4U], @"def"); + XCTAssertEqualObjects([dict objectForKey:1U], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:2U], @"def"); + XCTAssertEqualObjects([dict objectForKey:3U], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:4U], @"def"); const uint32_t kKeys2[] = { 2U, 3U }; - const id kValues2[] = { @"ghi", @"abc" }; + const id kObjects2[] = { @"ghi", @"abc" }; GPBUInt32ObjectDictionary *dict2 = - [[GPBUInt32ObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues2)]; + [[GPBUInt32ObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:1U], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:2U], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:3U], @"abc"); - XCTAssertEqualObjects([dict valueForKey:4U], @"def"); + XCTAssertEqualObjects([dict objectForKey:1U], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:2U], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:3U], @"abc"); + XCTAssertEqualObjects([dict objectForKey:4U], @"def"); [dict2 release]; [dict release]; diff --git a/objectivec/Tests/GPBDictionaryTests+UInt64.m b/objectivec/Tests/GPBDictionaryTests+UInt64.m index cebd6df2..b64d3a96 100644 --- a/objectivec/Tests/GPBDictionaryTests+UInt64.m +++ b/objectivec/Tests/GPBDictionaryTests+UInt64.m @@ -211,10 +211,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -568,10 +568,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -925,10 +925,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1282,10 +1282,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1639,10 +1639,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -1996,10 +1996,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2353,10 +2353,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -2710,10 +2710,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3071,10 +3071,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different values; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same values; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3366,48 +3366,48 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { GPBUInt64ObjectDictionary *dict = [[GPBUInt64ObjectDictionary alloc] init]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:31ULL]); - [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue, stop) + XCTAssertNil([dict objectForKey:31ULL]); + [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject, stop) XCTFail(@"Shouldn't get here!"); }]; [dict release]; } - (void)testOne { - GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionaryWithValue:@"abc" forKey:31ULL]; + GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:31ULL]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 1U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc"); - XCTAssertNil([dict valueForKey:32ULL]); - [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, id aValue, BOOL *stop) { + XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); + XCTAssertNil([dict objectForKey:32ULL]); + [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) { XCTAssertEqual(aKey, 31ULL); - XCTAssertEqualObjects(aValue, @"abc"); + XCTAssertEqualObjects(aObject, @"abc"); XCTAssertNotEqual(stop, NULL); }]; } - (void)testBasics { const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL }; - const id kValues[] = { @"abc", @"def", @"ghi" }; + const id kObjects[] = { @"abc", @"def", @"ghi" }; GPBUInt64ObjectDictionary *dict = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc"); - XCTAssertEqualObjects([dict valueForKey:32ULL], @"def"); - XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi"); - XCTAssertNil([dict valueForKey:34ULL]); + XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); + XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); + XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); + XCTAssertNil([dict objectForKey:34ULL]); __block NSUInteger idx = 0; uint64_t *seenKeys = malloc(3 * sizeof(uint64_t)); - id *seenValues = malloc(3 * sizeof(id)); - [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, id aValue, BOOL *stop) { + id *seenObjects = malloc(3 * sizeof(id)); + [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) { XCTAssertLessThan(idx, 3U); seenKeys[idx] = aKey; - seenValues[idx] = aValue; + seenObjects[idx] = aObject; XCTAssertNotEqual(stop, NULL); ++idx; }]; @@ -3416,18 +3416,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { for (int j = 0; (j < 3) && !foundKey; ++j) { if (kKeys[i] == seenKeys[j]) { foundKey = YES; - XCTAssertEqualObjects(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); + XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j); } } XCTAssertTrue(foundKey, @"i = %d", i); } free(seenKeys); - free(seenValues); + free(seenObjects); // Stopping the enumeration. idx = 0; - [dict enumerateKeysAndValuesUsingBlock:^(uint64_t aKey, id aValue, BOOL *stop) { - #pragma unused(aKey, aValue) + [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *stop) { + #pragma unused(aKey, aObject) if (idx == 1) *stop = YES; XCTAssertNotEqual(idx, 2U); ++idx; @@ -3438,33 +3438,33 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testEquality { const uint64_t kKeys1[] = { 31ULL, 32ULL, 33ULL, 34ULL }; const uint64_t kKeys2[] = { 32ULL, 31ULL, 34ULL }; - const id kValues1[] = { @"abc", @"def", @"ghi" }; - const id kValues2[] = { @"abc", @"jkl", @"ghi" }; - const id kValues3[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects1[] = { @"abc", @"def", @"ghi" }; + const id kObjects2[] = { @"abc", @"jkl", @"ghi" }; + const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt64ObjectDictionary *dict1 = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1); GPBUInt64ObjectDictionary *dict1prime = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues1)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict1prime); GPBUInt64ObjectDictionary *dict2 = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues2)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); GPBUInt64ObjectDictionary *dict3 = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues1 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues1)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects1)]; XCTAssertNotNil(dict3); GPBUInt64ObjectDictionary *dict4 = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues3 - forKeys:kKeys1 - count:GPBARRAYSIZE(kValues3)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects3 + forKeys:kKeys1 + count:GPBARRAYSIZE(kObjects3)]; XCTAssertNotNil(dict4); // 1/1Prime should be different objects, but equal. @@ -3473,10 +3473,10 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { // Equal, so they must have same hash. XCTAssertEqual([dict1 hash], [dict1prime hash]); - // 2 is save keys, different values; not equal. + // 2 is same keys, different objects; not equal. XCTAssertNotEqualObjects(dict1, dict2); - // 3 is different keys, samae values; not equal. + // 3 is different keys, same objects; not equal. XCTAssertNotEqualObjects(dict1, dict3); // 4 extra pair; not equal @@ -3491,11 +3491,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testCopy { const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt64ObjectDictionary *dict = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBUInt64ObjectDictionary *dict2 = [dict copy]; @@ -3512,11 +3512,11 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { - (void)testDictionaryFromDictionary { const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt64ObjectDictionary *dict = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); GPBUInt64ObjectDictionary *dict2 = @@ -3534,108 +3534,108 @@ static BOOL TestingEnum_IsValidValue(int32_t value) { XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 0U); - [dict setValue:@"abc" forKey:31ULL]; + [dict setObject:@"abc" forKey:31ULL]; XCTAssertEqual(dict.count, 1U); const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL }; - const id kValues[] = { @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"def", @"ghi", @"jkl" }; GPBUInt64ObjectDictionary *dict2 = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc"); - XCTAssertEqualObjects([dict valueForKey:32ULL], @"def"); - XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); + XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); + XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl"); [dict2 release]; } - (void)testRemove { const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt64ObjectDictionary *dict = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 4U); - [dict removeValueForKey:32ULL]; + [dict removeObjectForKey:32ULL]; XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc"); - XCTAssertNil([dict valueForKey:32ULL]); - XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); + XCTAssertNil([dict objectForKey:32ULL]); + XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl"); // Remove again does nothing. - [dict removeValueForKey:32ULL]; + [dict removeObjectForKey:32ULL]; XCTAssertEqual(dict.count, 3U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc"); - XCTAssertNil([dict valueForKey:32ULL]); - XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); + XCTAssertNil([dict objectForKey:32ULL]); + XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl"); - [dict removeValueForKey:34ULL]; + [dict removeObjectForKey:34ULL]; XCTAssertEqual(dict.count, 2U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc"); - XCTAssertNil([dict valueForKey:32ULL]); - XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi"); - XCTAssertNil([dict valueForKey:34ULL]); + XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); + XCTAssertNil([dict objectForKey:32ULL]); + XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); + XCTAssertNil([dict objectForKey:34ULL]); [dict removeAll]; XCTAssertEqual(dict.count, 0U); - XCTAssertNil([dict valueForKey:31ULL]); - XCTAssertNil([dict valueForKey:32ULL]); - XCTAssertNil([dict valueForKey:33ULL]); - XCTAssertNil([dict valueForKey:34ULL]); + XCTAssertNil([dict objectForKey:31ULL]); + XCTAssertNil([dict objectForKey:32ULL]); + XCTAssertNil([dict objectForKey:33ULL]); + XCTAssertNil([dict objectForKey:34ULL]); [dict release]; } - (void)testInplaceMutation { const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL }; - const id kValues[] = { @"abc", @"def", @"ghi", @"jkl" }; + const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; GPBUInt64ObjectDictionary *dict = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues - forKeys:kKeys - count:GPBARRAYSIZE(kValues)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects + forKeys:kKeys + count:GPBARRAYSIZE(kObjects)]; XCTAssertNotNil(dict); XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"abc"); - XCTAssertEqualObjects([dict valueForKey:32ULL], @"def"); - XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); + XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); + XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl"); - [dict setValue:@"jkl" forKey:31ULL]; + [dict setObject:@"jkl" forKey:31ULL]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:32ULL], @"def"); - XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:34ULL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); + XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl"); - [dict setValue:@"def" forKey:34ULL]; + [dict setObject:@"def" forKey:34ULL]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:32ULL], @"def"); - XCTAssertEqualObjects([dict valueForKey:33ULL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:34ULL], @"def"); + XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); + XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:34ULL], @"def"); const uint64_t kKeys2[] = { 32ULL, 33ULL }; - const id kValues2[] = { @"ghi", @"abc" }; + const id kObjects2[] = { @"ghi", @"abc" }; GPBUInt64ObjectDictionary *dict2 = - [[GPBUInt64ObjectDictionary alloc] initWithValues:kValues2 - forKeys:kKeys2 - count:GPBARRAYSIZE(kValues2)]; + [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2 + forKeys:kKeys2 + count:GPBARRAYSIZE(kObjects2)]; XCTAssertNotNil(dict2); [dict addEntriesFromDictionary:dict2]; XCTAssertEqual(dict.count, 4U); - XCTAssertEqualObjects([dict valueForKey:31ULL], @"jkl"); - XCTAssertEqualObjects([dict valueForKey:32ULL], @"ghi"); - XCTAssertEqualObjects([dict valueForKey:33ULL], @"abc"); - XCTAssertEqualObjects([dict valueForKey:34ULL], @"def"); + XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl"); + XCTAssertEqualObjects([dict objectForKey:32ULL], @"ghi"); + XCTAssertEqualObjects([dict objectForKey:33ULL], @"abc"); + XCTAssertEqualObjects([dict objectForKey:34ULL], @"def"); [dict2 release]; [dict release]; diff --git a/objectivec/Tests/GPBDictionaryTests.pddm b/objectivec/Tests/GPBDictionaryTests.pddm index ee26fac8..ada93c64 100644 --- a/objectivec/Tests/GPBDictionaryTests.pddm +++ b/objectivec/Tests/GPBDictionaryTests.pddm @@ -45,12 +45,12 @@ //%TESTS_FOR_ENUM_VALUE_RAW_ADDITIONS(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4) //%PDDM-DEFINE TESTS_FOR_POD_VALUE(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VACCESSOR, VAL1, VAL2, VAL3, VAL4) -//%TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, , POD, VACCESSOR, VAL1, VAL2, VAL3, VAL4) +//%TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, , value, POD, VACCESSOR, VAL1, VAL2, VAL3, VAL4) //%PDDM-DEFINE TESTS_FOR_POD_KEY_OBJECT_VALUE(KEY_NAME, KEY_TYPE, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VAL1, VAL2, VAL3, VAL4) -//%TESTS_COMMON(KEY_NAME, KEY_TYPE, , , KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, Objects, OBJECT, , VAL1, VAL2, VAL3, VAL4) +//%TESTS_COMMON(KEY_NAME, KEY_TYPE, , , KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, Objects, object, OBJECT, , VAL1, VAL2, VAL3, VAL4) -//%PDDM-DEFINE TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VSUFFIX, VHELPER, VACCESSOR, VAL1, VAL2, VAL3, VAL4) +//%PDDM-DEFINE TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, KEY3, KEY4, VALUE_NAME, VALUE_TYPE, VSUFFIX, VNAME, VHELPER, VACCESSOR, VAL1, VAL2, VAL3, VAL4) //%#pragma mark - KEY_NAME -> VALUE_NAME //% //%@interface GPB##KEY_NAME##VALUE_NAME##DictionaryTests : XCTestCase @@ -63,47 +63,47 @@ //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 0U); //%VALUE_NOT_FOUND##VHELPER(dict, KEY1) -//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) { -//% #pragma unused(aKey, aValue, stop) +//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) { +//% #pragma unused(aKey, a##VNAME$u, stop) //% XCTFail(@"Shouldn't get here!"); //% }]; //% [dict release]; //%} //% //%- (void)testOne { -//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithValue:VAL1 forKey:KEY1]; +//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VNAME$u##:VAL1 forKey:KEY1]; //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 1U); -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) //%VALUE_NOT_FOUND##VHELPER(dict, KEY2) -//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) { +//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) { //% XCTAssertEqual##KSUFFIX(aKey, KEY1); -//% XCTAssertEqual##VSUFFIX(aValue, VAL1); +//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1); //% XCTAssertNotEqual(stop, NULL); //% }]; //%} //% //%- (void)testBasics { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3 }; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 3U); -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) -//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3) //%VALUE_NOT_FOUND##VHELPER(dict, KEY4) //% //% __block NSUInteger idx = 0; //% KEY_TYPE KisP##*seenKeys = malloc(3 * sizeof(KEY_TYPE##KisP)); -//% VALUE_TYPE *seenValues = malloc(3 * sizeof(VALUE_TYPE)); -//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) { +//% VALUE_TYPE *seen##VNAME$u##s = malloc(3 * sizeof(VALUE_TYPE)); +//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) { //% XCTAssertLessThan(idx, 3U); //% seenKeys[idx] = aKey; -//% seenValues[idx] = aValue; +//% seen##VNAME$u##s[idx] = a##VNAME$u##; //% XCTAssertNotEqual(stop, NULL); //% ++idx; //% }]; @@ -112,18 +112,18 @@ //% for (int j = 0; (j < 3) && !foundKey; ++j) { //% if (COMPARE_KEYS##KSUFFIX(kKeys[i], seenKeys[j])) { //% foundKey = YES; -//% XCTAssertEqual##VSUFFIX(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); +//% XCTAssertEqual##VSUFFIX(k##VNAME$u##s[i], seen##VNAME$u##s[j], @"i = %d, j = %d", i, j); //% } //% } //% XCTAssertTrue(foundKey, @"i = %d", i); //% } //% free(seenKeys); -//% free(seenValues); +//% free(seen##VNAME$u##s); //% //% // Stopping the enumeration. //% idx = 0; -//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) { -//% #pragma unused(aKey, aValue) +//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) { +//% #pragma unused(aKey, a##VNAME$u) //% if (idx == 1) *stop = YES; //% XCTAssertNotEqual(idx, 2U); //% ++idx; @@ -134,33 +134,33 @@ //%- (void)testEquality { //% const KEY_TYPE KisP##kKeys1[] = { KEY1, KEY2, KEY3, KEY4 }; //% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY1, KEY4 }; -//% const VALUE_TYPE kValues1[] = { VAL1, VAL2, VAL3 }; -//% const VALUE_TYPE kValues2[] = { VAL1, VAL4, VAL3 }; -//% const VALUE_TYPE kValues3[] = { VAL1, VAL2, VAL3, VAL4 }; +//% const VALUE_TYPE k##VNAME$u##s1[] = { VAL1, VAL2, VAL3 }; +//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL1, VAL4, VAL3 }; +//% const VALUE_TYPE k##VNAME$u##s3[] = { VAL1, VAL2, VAL3, VAL4 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)]; //% XCTAssertNotNil(dict1); //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)]; //% XCTAssertNotNil(dict1prime); //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues2 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)]; //% XCTAssertNotNil(dict2); //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)]; //% XCTAssertNotNil(dict3); //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues3 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues3)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s3 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)]; //% XCTAssertNotNil(dict4); //% //% // 1/1Prime should be different objects, but equal. @@ -169,10 +169,10 @@ //% // Equal, so they must have same hash. //% XCTAssertEqual([dict1 hash], [dict1prime hash]); //% -//% // 2 is save keys, different values; not equal. +//% // 2 is same keys, different ##VNAME##s; not equal. //% XCTAssertNotEqualObjects(dict1, dict2); //% -//% // 3 is different keys, samae values; not equal. +//% // 3 is different keys, same ##VNAME##s; not equal. //% XCTAssertNotEqualObjects(dict1, dict3); //% //% // 4 extra pair; not equal @@ -187,11 +187,11 @@ //% //%- (void)testCopy { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 }; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy]; @@ -208,11 +208,11 @@ //% //%- (void)testDictionaryFromDictionary { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 }; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = @@ -230,56 +230,56 @@ //% XCTAssertNotNil(dict); //% //% XCTAssertEqual(dict.count, 0U); -//% [dict setValue:VAL1 forKey:KEY1]; +//% [dict set##VNAME$u##:VAL1 forKey:KEY1]; //% XCTAssertEqual(dict.count, 1U); //% //% const KEY_TYPE KisP##kKeys[] = { KEY2, KEY3, KEY4 }; -//% const VALUE_TYPE kValues[] = { VAL2, VAL3, VAL4 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL2, VAL3, VAL4 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict2); //% [dict add##VACCESSOR##EntriesFromDictionary:dict2]; //% XCTAssertEqual(dict.count, 4U); //% -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) -//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3) -//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4) //% [dict2 release]; //%} //% //%- (void)testRemove { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 }; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 4U); //% -//% [dict removeValueForKey:KEY2]; +//% [dict remove##VNAME$u##ForKey:KEY2]; //% XCTAssertEqual(dict.count, 3U); -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) //%VALUE_NOT_FOUND##VHELPER(dict, KEY2) -//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3) -//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4) //% //% // Remove again does nothing. -//% [dict removeValueForKey:KEY2]; +//% [dict remove##VNAME$u##ForKey:KEY2]; //% XCTAssertEqual(dict.count, 3U); -//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) //%VALUE_NOT_FOUND##VHELPER(dict, KEY2) -//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3) -//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4) //% -//% [dict removeValueForKey:KEY4]; +//% [dict remove##VNAME$u##ForKey:KEY4]; //% XCTAssertEqual(dict.count, 2U); -//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) //%VALUE_NOT_FOUND##VHELPER(dict, KEY2) -//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3) //%VALUE_NOT_FOUND##VHELPER(dict, KEY4) //% //% [dict removeAll]; @@ -293,45 +293,45 @@ //% //%- (void)testInplaceMutation { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2, KEY3, KEY4 }; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2, VAL3, VAL4 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2, VAL3, VAL4 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 4U); -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) -//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3) -//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4) //% -//% [dict setValue:VAL4 forKey:KEY1]; +//% [dict set##VNAME$u##:VAL4 forKey:KEY1]; //% XCTAssertEqual(dict.count, 4U); -//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL4) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) -//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3) -//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL4) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL4) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL4) //% -//% [dict setValue:VAL2 forKey:KEY4]; +//% [dict set##VNAME$u##:VAL2 forKey:KEY4]; //% XCTAssertEqual(dict.count, 4U); -//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL4) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) -//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL3) -//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL4) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL3) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL2) //% //% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY3 }; -//% const VALUE_TYPE kValues2[] = { VAL3, VAL1 }; +//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL3, VAL1 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues2 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)]; //% XCTAssertNotNil(dict2); //% [dict add##VACCESSOR##EntriesFromDictionary:dict2]; //% XCTAssertEqual(dict.count, 4U); -//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL4) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL3) -//%TEST_VALUE##VHELPER(dict, value, KEY3, VAL1) -//%TEST_VALUE##VHELPER(dict, value, KEY4, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL4) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL3) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY3, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY4, VAL2) //% //% [dict2 release]; //% [dict release]; @@ -466,10 +466,10 @@ //% // Equal, so they must have same hash. //% XCTAssertEqual([dict1 hash], [dict1prime hash]); //% -//% // 2 is save keys, different values; not equal. +//% // 2 is same keys, different values; not equal. //% XCTAssertNotEqualObjects(dict1, dict2); //% -//% // 3 is different keys, samae values; not equal. +//% // 3 is different keys, same values; not equal. //% XCTAssertNotEqualObjects(dict1, dict3); //% //% // 4 extra pair; not equal @@ -709,9 +709,9 @@ //%PDDM-DEFINE DECLARE_VALUE_STORAGEOBJECT(VALUE_TYPE, NAME) // Empty //%PDDM-DEFINE VALUE_NOT_FOUNDOBJECT(DICT, KEY) -//% XCTAssertNil([DICT valueForKey:KEY]); +//% XCTAssertNil([DICT objectForKey:KEY]); //%PDDM-DEFINE TEST_VALUEOBJECT(DICT, STORAGE, KEY, VALUE) -//% XCTAssertEqualObjects([DICT valueForKey:KEY], VALUE); +//% XCTAssertEqualObjects([DICT objectForKey:KEY], VALUE); //%PDDM-DEFINE COMPARE_KEYSObjects(KEY1, KEY2) //%[KEY1 isEqual:KEY2] @@ -768,12 +768,12 @@ //TODO(thomasvl): enum tests //%PDDM-DEFINE BOOL_TESTS_FOR_POD_VALUE(VALUE_NAME, VALUE_TYPE, VAL1, VAL2) -//%BOOL_TESTS_COMMON(Bool, BOOL, , , YES, NO, VALUE_NAME, VALUE_TYPE, , POD, VAL1, VAL2) +//%BOOL_TESTS_COMMON(Bool, BOOL, , , YES, NO, VALUE_NAME, VALUE_TYPE, , value, POD, VAL1, VAL2) //%PDDM-DEFINE TESTS_FOR_BOOL_KEY_OBJECT_VALUE(VALUE_NAME, VALUE_TYPE, VAL1, VAL2) -//%BOOL_TESTS_COMMON(Bool, BOOL, , , YES, NO, VALUE_NAME, VALUE_TYPE, Objects, OBJECT, VAL1, VAL2) +//%BOOL_TESTS_COMMON(Bool, BOOL, , , YES, NO, VALUE_NAME, VALUE_TYPE, Objects, object, OBJECT, VAL1, VAL2) -//%PDDM-DEFINE BOOL_TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, VALUE_NAME, VALUE_TYPE, VSUFFIX, VHELPER, VAL1, VAL2) +//%PDDM-DEFINE BOOL_TESTS_COMMON(KEY_NAME, KEY_TYPE, KisP, KSUFFIX, KEY1, KEY2, VALUE_NAME, VALUE_TYPE, VSUFFIX, VNAME, VHELPER, VAL1, VAL2) //%#pragma mark - KEY_NAME -> VALUE_NAME //% //%@interface GPB##KEY_NAME##VALUE_NAME##DictionaryTests : XCTestCase @@ -786,45 +786,45 @@ //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 0U); //%VALUE_NOT_FOUND##VHELPER(dict, KEY1) -//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) { -//% #pragma unused(aKey, aValue, stop) +//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) { +//% #pragma unused(aKey, a##VNAME$u##, stop) //% XCTFail(@"Shouldn't get here!"); //% }]; //% [dict release]; //%} //% //%- (void)testOne { -//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithValue:VAL1 forKey:KEY1]; +//% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VNAME$u##:VAL1 forKey:KEY1]; //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 1U); -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) //%VALUE_NOT_FOUND##VHELPER(dict, KEY2) -//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) { +//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u, BOOL *stop) { //% XCTAssertEqual##KSUFFIX(aKey, KEY1); -//% XCTAssertEqual##VSUFFIX(aValue, VAL1); +//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1); //% XCTAssertNotEqual(stop, NULL); //% }]; //%} //% //%- (void)testBasics { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 }; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 2U); -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) //% //% __block NSUInteger idx = 0; //% KEY_TYPE KisP##*seenKeys = malloc(2 * sizeof(KEY_TYPE##KisP)); -//% VALUE_TYPE *seenValues = malloc(2 * sizeof(VALUE_TYPE)); -//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) { +//% VALUE_TYPE *seen##VNAME$u##s = malloc(2 * sizeof(VALUE_TYPE)); +//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) { //% XCTAssertLessThan(idx, 2U); //% seenKeys[idx] = aKey; -//% seenValues[idx] = aValue; +//% seen##VNAME$u##s[idx] = a##VNAME$u; //% XCTAssertNotEqual(stop, NULL); //% ++idx; //% }]; @@ -833,18 +833,18 @@ //% for (int j = 0; (j < 2) && !foundKey; ++j) { //% if (COMPARE_KEYS##KSUFFIX(kKeys[i], seenKeys[j])) { //% foundKey = YES; -//% XCTAssertEqual##VSUFFIX(kValues[i], seenValues[j], @"i = %d, j = %d", i, j); +//% XCTAssertEqual##VSUFFIX(k##VNAME$u##s[i], seen##VNAME$u##s[j], @"i = %d, j = %d", i, j); //% } //% } //% XCTAssertTrue(foundKey, @"i = %d", i); //% } //% free(seenKeys); -//% free(seenValues); +//% free(seen##VNAME$u##s); //% //% // Stopping the enumeration. //% idx = 0; -//% [dict enumerateKeysAndValuesUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE aValue, BOOL *stop) { -//% #pragma unused(aKey, aValue) +//% [dict enumerateKeysAnd##VNAME$u##sUsingBlock:^(KEY_TYPE KisP##aKey, VALUE_TYPE a##VNAME$u##, BOOL *stop) { +//% #pragma unused(aKey, a##VNAME$u) //% if (idx == 0) *stop = YES; //% XCTAssertNotEqual(idx, 2U); //% ++idx; @@ -855,33 +855,33 @@ //%- (void)testEquality { //% const KEY_TYPE KisP##kKeys1[] = { KEY1, KEY2 }; //% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY1 }; -//% const VALUE_TYPE kValues1[] = { VAL1, VAL2 }; -//% const VALUE_TYPE kValues2[] = { VAL2, VAL1 }; -//% const VALUE_TYPE kValues3[] = { VAL2 }; +//% const VALUE_TYPE k##VNAME$u##s1[] = { VAL1, VAL2 }; +//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL2, VAL1 }; +//% const VALUE_TYPE k##VNAME$u##s3[] = { VAL2 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)]; //% XCTAssertNotNil(dict1); //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict1prime = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)]; //% XCTAssertNotNil(dict1prime); //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues2 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)]; //% XCTAssertNotNil(dict2); //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict3 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues1 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues1)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s1)]; //% XCTAssertNotNil(dict3); //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict4 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues3 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys1 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues3)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s3 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys1 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s3)]; //% XCTAssertNotNil(dict4); //% //% // 1/1Prime should be different objects, but equal. @@ -890,10 +890,10 @@ //% // Equal, so they must have same hash. //% XCTAssertEqual([dict1 hash], [dict1prime hash]); //% -//% // 2 is save keys, different values; not equal. +//% // 2 is same keys, different ##VNAME##s; not equal. //% XCTAssertNotEqualObjects(dict1, dict2); //% -//% // 3 is different keys, samae values; not equal. +//% // 3 is different keys, same ##VNAME##s; not equal. //% XCTAssertNotEqualObjects(dict1, dict3); //% //% // 4 Fewer pairs; not equal @@ -908,11 +908,11 @@ //% //%- (void)testCopy { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 }; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = [dict copy]; @@ -929,11 +929,11 @@ //% //%- (void)testDictionaryFromDictionary { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 }; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = @@ -951,43 +951,43 @@ //% XCTAssertNotNil(dict); //% //% XCTAssertEqual(dict.count, 0U); -//% [dict setValue:VAL1 forKey:KEY1]; +//% [dict set##VNAME$u:VAL1 forKey:KEY1]; //% XCTAssertEqual(dict.count, 1U); //% //% const KEY_TYPE KisP##kKeys[] = { KEY2 }; -//% const VALUE_TYPE kValues[] = { VAL2 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL2 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict2); //% [dict addEntriesFromDictionary:dict2]; //% XCTAssertEqual(dict.count, 2U); //% -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) //% [dict2 release]; //%} //% //%- (void)testRemove { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2}; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 2U); //% -//% [dict removeValueForKey:KEY2]; +//% [dict remove##VNAME$u##ForKey:KEY2]; //% XCTAssertEqual(dict.count, 1U); -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) //%VALUE_NOT_FOUND##VHELPER(dict, KEY2) //% //% // Remove again does nothing. -//% [dict removeValueForKey:KEY2]; +//% [dict remove##VNAME$u##ForKey:KEY2]; //% XCTAssertEqual(dict.count, 1U); -//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) //%VALUE_NOT_FOUND##VHELPER(dict, KEY2) //% //% [dict removeAll]; @@ -999,37 +999,37 @@ //% //%- (void)testInplaceMutation { //% const KEY_TYPE KisP##kKeys[] = { KEY1, KEY2 }; -//% const VALUE_TYPE kValues[] = { VAL1, VAL2 }; +//% const VALUE_TYPE k##VNAME$u##s[] = { VAL1, VAL2 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s)]; //% XCTAssertNotNil(dict); //% XCTAssertEqual(dict.count, 2U); -//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, value)TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) +//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) //% -//% [dict setValue:VAL2 forKey:KEY1]; +//% [dict set##VNAME$u##:VAL2 forKey:KEY1]; //% XCTAssertEqual(dict.count, 2U); -//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL2) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) //% -//% [dict setValue:VAL1 forKey:KEY2]; +//% [dict set##VNAME$u##:VAL1 forKey:KEY2]; //% XCTAssertEqual(dict.count, 2U); -//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL2) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL1) //% //% const KEY_TYPE KisP##kKeys2[] = { KEY2, KEY1 }; -//% const VALUE_TYPE kValues2[] = { VAL2, VAL1 }; +//% const VALUE_TYPE k##VNAME$u##s2[] = { VAL2, VAL1 }; //% GPB##KEY_NAME##VALUE_NAME##Dictionary *dict2 = -//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValues:kValues2 -//% KEY_NAME$S VALUE_NAME$S forKeys:kKeys2 -//% KEY_NAME$S VALUE_NAME$S count:GPBARRAYSIZE(kValues2)]; +//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWith##VNAME$u##s:k##VNAME$u##s2 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## forKeys:kKeys2 +//% KEY_NAME$S VALUE_NAME$S ##VNAME$S## count:GPBARRAYSIZE(k##VNAME$u##s2)]; //% XCTAssertNotNil(dict2); //% [dict addEntriesFromDictionary:dict2]; //% XCTAssertEqual(dict.count, 2U); -//%TEST_VALUE##VHELPER(dict, value, KEY1, VAL1) -//%TEST_VALUE##VHELPER(dict, value, KEY2, VAL2) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY1, VAL1) +//%TEST_VALUE##VHELPER(dict, VNAME, KEY2, VAL2) //% //% [dict2 release]; //% [dict release]; diff --git a/objectivec/Tests/GPBMessageTests+Merge.m b/objectivec/Tests/GPBMessageTests+Merge.m index 3b6fdbd4..a3908aab 100644 --- a/objectivec/Tests/GPBMessageTests+Merge.m +++ b/objectivec/Tests/GPBMessageTests+Merge.m @@ -676,20 +676,21 @@ TestAllTypes *subMsg = [TestAllTypes message]; subMsg.repeatedInt32Array = [GPBInt32Array arrayWithValue:100]; msg1.mapInt32Message = [GPBInt32ObjectDictionary dictionary]; - [msg1.mapInt32Message setValue:subMsg forKey:0]; + [msg1.mapInt32Message setObject:subMsg forKey:0]; subMsg = nil; subMsg = [TestAllTypes message]; subMsg.repeatedInt32Array = [GPBInt32Array arrayWithValue:101]; msg2.mapInt32Message = [GPBInt32ObjectDictionary dictionary]; - [msg2.mapInt32Message setValue:subMsg forKey:0]; + + [msg2.mapInt32Message setObject:subMsg forKey:0]; subMsg = nil; [msg1 mergeFrom:msg2]; // Checks repeated field is overwritten. XCTAssertEqual(msg1.mapInt32Message.count, 1U); - subMsg = [msg1.mapInt32Message valueForKey:0]; + subMsg = [msg1.mapInt32Message objectForKey:0]; XCTAssertNotNil(subMsg); XCTAssertEqual(subMsg.repeatedInt32Array.count, 1U); XCTAssertEqual([subMsg.repeatedInt32Array valueAtIndex:0], 101); diff --git a/objectivec/Tests/GPBMessageTests+Runtime.m b/objectivec/Tests/GPBMessageTests+Runtime.m index 8942a843..e536bfec 100644 --- a/objectivec/Tests/GPBMessageTests+Runtime.m +++ b/objectivec/Tests/GPBMessageTests+Runtime.m @@ -2059,9 +2059,9 @@ // Ensure the messages are unique per map. [msg1.mapInt32ForeignMessage - enumerateKeysAndValuesUsingBlock:^(int32_t key, id value, BOOL *stop) { + enumerateKeysAndObjectsUsingBlock:^(int32_t key, id value, BOOL *stop) { #pragma unused(stop) - ForeignMessage *subMsg2 = [msg2.mapInt32ForeignMessage valueForKey:key]; + ForeignMessage *subMsg2 = [msg2.mapInt32ForeignMessage objectForKey:key]; XCTAssertNotEqual(value, subMsg2); // Ptr compare, new object. }]; } @@ -2075,7 +2075,7 @@ // Add an uninitialized message. TestRequired *subMsg = [[TestRequired alloc] init]; msg.mapField = [GPBInt32ObjectDictionary dictionary]; - [msg.mapField setValue:subMsg forKey:0]; + [msg.mapField setObject:subMsg forKey:0]; XCTAssertFalse(msg.initialized); // Initialize uninitialized message diff --git a/objectivec/Tests/GPBMessageTests+Serialization.m b/objectivec/Tests/GPBMessageTests+Serialization.m index ae4be9e5..4dcca7a3 100644 --- a/objectivec/Tests/GPBMessageTests+Serialization.m +++ b/objectivec/Tests/GPBMessageTests+Serialization.m @@ -994,16 +994,16 @@ static NSData *DataFromCStr(const char *str) { val2.optionalInt32 = 129; [msg.mapStringMessage setValue:val1 forKey:@"228"]; [msg.mapStringMessage setValue:val2 forKey:@"2029"]; - [msg.mapInt32Bytes setValue:DataFromCStr("1030 bytes") forKey:230]; - [msg.mapInt32Bytes setValue:DataFromCStr("131") forKey:2031]; + [msg.mapInt32Bytes setObject:DataFromCStr("1030 bytes") forKey:230]; + [msg.mapInt32Bytes setObject:DataFromCStr("131") forKey:2031]; [msg.mapInt32Enum setValue:Message2_Enum_Bar forKey:232]; [msg.mapInt32Enum setValue:Message2_Enum_Baz forKey:2033]; Message2 *val3 = [[Message2 alloc] init]; val3.optionalInt32 = 1034; Message2 *val4 = [[Message2 alloc] init]; val4.optionalInt32 = 135; - [msg.mapInt32Message setValue:val3 forKey:234]; - [msg.mapInt32Message setValue:val4 forKey:2035]; + [msg.mapInt32Message setObject:val3 forKey:234]; + [msg.mapInt32Message setObject:val4 forKey:2035]; NSData *data = [msg data]; Message2 *msg2 = [[Message2 alloc] initWithData:data error:NULL]; diff --git a/objectivec/Tests/GPBObjectiveCPlusPlusTest.mm b/objectivec/Tests/GPBObjectiveCPlusPlusTest.mm new file mode 100644 index 00000000..9ba8fd0b --- /dev/null +++ b/objectivec/Tests/GPBObjectiveCPlusPlusTest.mm @@ -0,0 +1,69 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2013 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +#import "GPBTestUtilities.h" + + +// +// This is just a compile test (here to make sure things never regress). +// +// Objective C++ can run into issues with how the NS_ENUM/CF_ENUM declartion +// works because of the C++ spec being used for that compilation unit. So +// the fact that these imports all work without errors/warning means things +// are still good. +// +// The "well know types" should have cross file enums needing imports. +#import "GPBProtocolBuffers.h" +// Some of the tests explicitly use cross file enums also. +#import "google/protobuf/Unittest.pbobjc.h" +#import "google/protobuf/UnittestImport.pbobjc.h" + +// Sanity check the conditions of the test within the Xcode project. +#if !__cplusplus + #error This isn't compiled as Objective C++? +#elif __cplusplus >= 201103L + // If this trips, it means the Xcode default might have change (or someone + // edited the testing project) and it might be time to revisit the GPB_ENUM + // define in GPBBootstrap.h. + #warning Did the Xcode default for C++ spec change? +#endif + + +// Dummy XCTest. +@interface GPBObjectiveCPlusPlusTests : GPBTestCase +@end + +@implementation GPBObjectiveCPlusPlusTests +- (void)testCPlusPlus { + // Nothing, This was a compile test. + XCTAssertTrue(YES); +} +@end diff --git a/objectivec/Tests/GPBTestUtilities.m b/objectivec/Tests/GPBTestUtilities.m index 3d85c744..726761a7 100644 --- a/objectivec/Tests/GPBTestUtilities.m +++ b/objectivec/Tests/GPBTestUtilities.m @@ -1110,7 +1110,7 @@ const uint32_t kGPBDefaultRepeatCount = 2; [dataStr release]; NSData *data = [[NSData alloc] initWithUint32_gpbtu:i + 1]; - [message.mapInt32Bytes setValue:data forKey:113 + i * 100]; + [message.mapInt32Bytes setObject:data forKey:113 + i * 100]; [data release]; [message.mapInt32Enum @@ -1119,7 +1119,7 @@ const uint32_t kGPBDefaultRepeatCount = 2; ForeignMessage *subMsg = [[ForeignMessage alloc] init]; subMsg.c = i + 1; - [message.mapInt32ForeignMessage setValue:subMsg forKey:115 + i * 100]; + [message.mapInt32ForeignMessage setObject:subMsg forKey:115 + i * 100]; [subMsg release]; } } diff --git a/objectivec/Tests/GPBWireFormatTests.m b/objectivec/Tests/GPBWireFormatTests.m index c1244212..3fab20b7 100644 --- a/objectivec/Tests/GPBWireFormatTests.m +++ b/objectivec/Tests/GPBWireFormatTests.m @@ -167,12 +167,12 @@ const int kUnknownTypeId = 1550055; XCTAssertEqual([raw.itemArray[2] typeId], kUnknownTypeId); TestMessageSetExtension1* message1 = - [TestMessageSetExtension1 parseFromData:[raw.itemArray[0] message] + [TestMessageSetExtension1 parseFromData:[((RawMessageSet_Item*)raw.itemArray[0]) message] error:NULL]; XCTAssertEqual(message1.i, 123); TestMessageSetExtension2* message2 = - [TestMessageSetExtension2 parseFromData:[raw.itemArray[1] message] + [TestMessageSetExtension2 parseFromData:[((RawMessageSet_Item*)raw.itemArray[1]) message] error:NULL]; XCTAssertEqualObjects(message2.str, @"foo"); |