Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: third_party/protobuf/objectivec/Tests/GPBDictionaryTests+UInt64.m

Issue 1983203003: Update third_party/protobuf to protobuf-v3.0.0-beta-3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: owners Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2015 Google Inc. All rights reserved. 2 // Copyright 2015 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/ 3 // https://developers.google.com/protocol-buffers/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 3345 matching lines...) Expand 10 before | Expand all | Expand 10 after
3356 @end 3356 @end
3357 3357
3358 #pragma mark - UInt64 -> Object 3358 #pragma mark - UInt64 -> Object
3359 3359
3360 @interface GPBUInt64ObjectDictionaryTests : XCTestCase 3360 @interface GPBUInt64ObjectDictionaryTests : XCTestCase
3361 @end 3361 @end
3362 3362
3363 @implementation GPBUInt64ObjectDictionaryTests 3363 @implementation GPBUInt64ObjectDictionaryTests
3364 3364
3365 - (void)testEmpty { 3365 - (void)testEmpty {
3366 GPBUInt64ObjectDictionary *dict = [[GPBUInt64ObjectDictionary alloc] init]; 3366 GPBUInt64ObjectDictionary<NSString*> *dict = [[GPBUInt64ObjectDictionary alloc ] init];
3367 XCTAssertNotNil(dict); 3367 XCTAssertNotNil(dict);
3368 XCTAssertEqual(dict.count, 0U); 3368 XCTAssertEqual(dict.count, 0U);
3369 XCTAssertNil([dict objectForKey:31ULL]); 3369 XCTAssertNil([dict objectForKey:31ULL]);
3370 [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *sto p) { 3370 [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BO OL *stop) {
3371 #pragma unused(aKey, aObject, stop) 3371 #pragma unused(aKey, aObject, stop)
3372 XCTFail(@"Shouldn't get here!"); 3372 XCTFail(@"Shouldn't get here!");
3373 }]; 3373 }];
3374 [dict release]; 3374 [dict release];
3375 } 3375 }
3376 3376
3377 - (void)testOne { 3377 - (void)testOne {
3378 GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionaryWithObj ect:@"abc" forKey:31ULL]; 3378 GPBUInt64ObjectDictionary<NSString*> *dict = [GPBUInt64ObjectDictionary dictio naryWithObject:@"abc" forKey:31ULL];
3379 XCTAssertNotNil(dict); 3379 XCTAssertNotNil(dict);
3380 XCTAssertEqual(dict.count, 1U); 3380 XCTAssertEqual(dict.count, 1U);
3381 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); 3381 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
3382 XCTAssertNil([dict objectForKey:32ULL]); 3382 XCTAssertNil([dict objectForKey:32ULL]);
3383 [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *sto p) { 3383 [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BO OL *stop) {
3384 XCTAssertEqual(aKey, 31ULL); 3384 XCTAssertEqual(aKey, 31ULL);
3385 XCTAssertEqualObjects(aObject, @"abc"); 3385 XCTAssertEqualObjects(aObject, @"abc");
3386 XCTAssertNotEqual(stop, NULL); 3386 XCTAssertNotEqual(stop, NULL);
3387 }]; 3387 }];
3388 } 3388 }
3389 3389
3390 - (void)testBasics { 3390 - (void)testBasics {
3391 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL }; 3391 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL };
3392 const id kObjects[] = { @"abc", @"def", @"ghi" }; 3392 const NSString* kObjects[] = { @"abc", @"def", @"ghi" };
3393 GPBUInt64ObjectDictionary *dict = 3393 GPBUInt64ObjectDictionary<NSString*> *dict =
3394 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects 3394 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
3395 forKeys:kKeys 3395 forKeys:kKeys
3396 count:GPBARRAYSIZE(kObjects)] ; 3396 count:GPBARRAYSIZE(kObjects)] ;
3397 XCTAssertNotNil(dict); 3397 XCTAssertNotNil(dict);
3398 XCTAssertEqual(dict.count, 3U); 3398 XCTAssertEqual(dict.count, 3U);
3399 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); 3399 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
3400 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); 3400 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
3401 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); 3401 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
3402 XCTAssertNil([dict objectForKey:34ULL]); 3402 XCTAssertNil([dict objectForKey:34ULL]);
3403 3403
3404 __block NSUInteger idx = 0; 3404 __block NSUInteger idx = 0;
3405 uint64_t *seenKeys = malloc(3 * sizeof(uint64_t)); 3405 uint64_t *seenKeys = malloc(3 * sizeof(uint64_t));
3406 id *seenObjects = malloc(3 * sizeof(id)); 3406 NSString* *seenObjects = malloc(3 * sizeof(NSString*));
3407 [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *sto p) { 3407 [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BO OL *stop) {
3408 XCTAssertLessThan(idx, 3U); 3408 XCTAssertLessThan(idx, 3U);
3409 seenKeys[idx] = aKey; 3409 seenKeys[idx] = aKey;
3410 seenObjects[idx] = aObject; 3410 seenObjects[idx] = aObject;
3411 XCTAssertNotEqual(stop, NULL); 3411 XCTAssertNotEqual(stop, NULL);
3412 ++idx; 3412 ++idx;
3413 }]; 3413 }];
3414 for (int i = 0; i < 3; ++i) { 3414 for (int i = 0; i < 3; ++i) {
3415 BOOL foundKey = NO; 3415 BOOL foundKey = NO;
3416 for (int j = 0; (j < 3) && !foundKey; ++j) { 3416 for (int j = 0; (j < 3) && !foundKey; ++j) {
3417 if (kKeys[i] == seenKeys[j]) { 3417 if (kKeys[i] == seenKeys[j]) {
3418 foundKey = YES; 3418 foundKey = YES;
3419 XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j); 3419 XCTAssertEqualObjects(kObjects[i], seenObjects[j], @"i = %d, j = %d", i, j);
3420 } 3420 }
3421 } 3421 }
3422 XCTAssertTrue(foundKey, @"i = %d", i); 3422 XCTAssertTrue(foundKey, @"i = %d", i);
3423 } 3423 }
3424 free(seenKeys); 3424 free(seenKeys);
3425 free(seenObjects); 3425 free(seenObjects);
3426 3426
3427 // Stopping the enumeration. 3427 // Stopping the enumeration.
3428 idx = 0; 3428 idx = 0;
3429 [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, id aObject, BOOL *sto p) { 3429 [dict enumerateKeysAndObjectsUsingBlock:^(uint64_t aKey, NSString* aObject, BO OL *stop) {
3430 #pragma unused(aKey, aObject) 3430 #pragma unused(aKey, aObject)
3431 if (idx == 1) *stop = YES; 3431 if (idx == 1) *stop = YES;
3432 XCTAssertNotEqual(idx, 2U); 3432 XCTAssertNotEqual(idx, 2U);
3433 ++idx; 3433 ++idx;
3434 }]; 3434 }];
3435 [dict release]; 3435 [dict release];
3436 } 3436 }
3437 3437
3438 - (void)testEquality { 3438 - (void)testEquality {
3439 const uint64_t kKeys1[] = { 31ULL, 32ULL, 33ULL, 34ULL }; 3439 const uint64_t kKeys1[] = { 31ULL, 32ULL, 33ULL, 34ULL };
3440 const uint64_t kKeys2[] = { 32ULL, 31ULL, 34ULL }; 3440 const uint64_t kKeys2[] = { 32ULL, 31ULL, 34ULL };
3441 const id kObjects1[] = { @"abc", @"def", @"ghi" }; 3441 const NSString* kObjects1[] = { @"abc", @"def", @"ghi" };
3442 const id kObjects2[] = { @"abc", @"jkl", @"ghi" }; 3442 const NSString* kObjects2[] = { @"abc", @"jkl", @"ghi" };
3443 const id kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" }; 3443 const NSString* kObjects3[] = { @"abc", @"def", @"ghi", @"jkl" };
3444 GPBUInt64ObjectDictionary *dict1 = 3444 GPBUInt64ObjectDictionary<NSString*> *dict1 =
3445 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1 3445 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
3446 forKeys:kKeys1 3446 forKeys:kKeys1
3447 count:GPBARRAYSIZE(kObjects1) ]; 3447 count:GPBARRAYSIZE(kObjects1) ];
3448 XCTAssertNotNil(dict1); 3448 XCTAssertNotNil(dict1);
3449 GPBUInt64ObjectDictionary *dict1prime = 3449 GPBUInt64ObjectDictionary<NSString*> *dict1prime =
3450 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1 3450 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
3451 forKeys:kKeys1 3451 forKeys:kKeys1
3452 count:GPBARRAYSIZE(kObjects1) ]; 3452 count:GPBARRAYSIZE(kObjects1) ];
3453 XCTAssertNotNil(dict1prime); 3453 XCTAssertNotNil(dict1prime);
3454 GPBUInt64ObjectDictionary *dict2 = 3454 GPBUInt64ObjectDictionary<NSString*> *dict2 =
3455 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2 3455 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2
3456 forKeys:kKeys1 3456 forKeys:kKeys1
3457 count:GPBARRAYSIZE(kObjects2) ]; 3457 count:GPBARRAYSIZE(kObjects2) ];
3458 XCTAssertNotNil(dict2); 3458 XCTAssertNotNil(dict2);
3459 GPBUInt64ObjectDictionary *dict3 = 3459 GPBUInt64ObjectDictionary<NSString*> *dict3 =
3460 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1 3460 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects1
3461 forKeys:kKeys2 3461 forKeys:kKeys2
3462 count:GPBARRAYSIZE(kObjects1) ]; 3462 count:GPBARRAYSIZE(kObjects1) ];
3463 XCTAssertNotNil(dict3); 3463 XCTAssertNotNil(dict3);
3464 GPBUInt64ObjectDictionary *dict4 = 3464 GPBUInt64ObjectDictionary<NSString*> *dict4 =
3465 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects3 3465 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects3
3466 forKeys:kKeys1 3466 forKeys:kKeys1
3467 count:GPBARRAYSIZE(kObjects3) ]; 3467 count:GPBARRAYSIZE(kObjects3) ];
3468 XCTAssertNotNil(dict4); 3468 XCTAssertNotNil(dict4);
3469 3469
3470 // 1/1Prime should be different objects, but equal. 3470 // 1/1Prime should be different objects, but equal.
3471 XCTAssertNotEqual(dict1, dict1prime); 3471 XCTAssertNotEqual(dict1, dict1prime);
3472 XCTAssertEqualObjects(dict1, dict1prime); 3472 XCTAssertEqualObjects(dict1, dict1prime);
3473 // Equal, so they must have same hash. 3473 // Equal, so they must have same hash.
3474 XCTAssertEqual([dict1 hash], [dict1prime hash]); 3474 XCTAssertEqual([dict1 hash], [dict1prime hash]);
3475 3475
3476 // 2 is same keys, different objects; not equal. 3476 // 2 is same keys, different objects; not equal.
3477 XCTAssertNotEqualObjects(dict1, dict2); 3477 XCTAssertNotEqualObjects(dict1, dict2);
3478 3478
3479 // 3 is different keys, same objects; not equal. 3479 // 3 is different keys, same objects; not equal.
3480 XCTAssertNotEqualObjects(dict1, dict3); 3480 XCTAssertNotEqualObjects(dict1, dict3);
3481 3481
3482 // 4 extra pair; not equal 3482 // 4 extra pair; not equal
3483 XCTAssertNotEqualObjects(dict1, dict4); 3483 XCTAssertNotEqualObjects(dict1, dict4);
3484 3484
3485 [dict1 release]; 3485 [dict1 release];
3486 [dict1prime release]; 3486 [dict1prime release];
3487 [dict2 release]; 3487 [dict2 release];
3488 [dict3 release]; 3488 [dict3 release];
3489 [dict4 release]; 3489 [dict4 release];
3490 } 3490 }
3491 3491
3492 - (void)testCopy { 3492 - (void)testCopy {
3493 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL }; 3493 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
3494 const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; 3494 const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
3495 GPBUInt64ObjectDictionary *dict = 3495 GPBUInt64ObjectDictionary<NSString*> *dict =
3496 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects 3496 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
3497 forKeys:kKeys 3497 forKeys:kKeys
3498 count:GPBARRAYSIZE(kObjects)] ; 3498 count:GPBARRAYSIZE(kObjects)] ;
3499 XCTAssertNotNil(dict); 3499 XCTAssertNotNil(dict);
3500 3500
3501 GPBUInt64ObjectDictionary *dict2 = [dict copy]; 3501 GPBUInt64ObjectDictionary<NSString*> *dict2 = [dict copy];
3502 XCTAssertNotNil(dict2); 3502 XCTAssertNotNil(dict2);
3503 3503
3504 // Should be new object but equal. 3504 // Should be new object but equal.
3505 XCTAssertNotEqual(dict, dict2); 3505 XCTAssertNotEqual(dict, dict2);
3506 XCTAssertEqualObjects(dict, dict2); 3506 XCTAssertEqualObjects(dict, dict2);
3507 XCTAssertTrue([dict2 isKindOfClass:[GPBUInt64ObjectDictionary class]]); 3507 XCTAssertTrue([dict2 isKindOfClass:[GPBUInt64ObjectDictionary class]]);
3508 3508
3509 [dict2 release]; 3509 [dict2 release];
3510 [dict release]; 3510 [dict release];
3511 } 3511 }
3512 3512
3513 - (void)testDictionaryFromDictionary { 3513 - (void)testDictionaryFromDictionary {
3514 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL }; 3514 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
3515 const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; 3515 const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
3516 GPBUInt64ObjectDictionary *dict = 3516 GPBUInt64ObjectDictionary<NSString*> *dict =
3517 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects 3517 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
3518 forKeys:kKeys 3518 forKeys:kKeys
3519 count:GPBARRAYSIZE(kObjects)] ; 3519 count:GPBARRAYSIZE(kObjects)] ;
3520 XCTAssertNotNil(dict); 3520 XCTAssertNotNil(dict);
3521 3521
3522 GPBUInt64ObjectDictionary *dict2 = 3522 GPBUInt64ObjectDictionary<NSString*> *dict2 =
3523 [GPBUInt64ObjectDictionary dictionaryWithDictionary:dict]; 3523 [GPBUInt64ObjectDictionary dictionaryWithDictionary:dict];
3524 XCTAssertNotNil(dict2); 3524 XCTAssertNotNil(dict2);
3525 3525
3526 // Should be new pointer, but equal objects. 3526 // Should be new pointer, but equal objects.
3527 XCTAssertNotEqual(dict, dict2); 3527 XCTAssertNotEqual(dict, dict2);
3528 XCTAssertEqualObjects(dict, dict2); 3528 XCTAssertEqualObjects(dict, dict2);
3529 [dict release]; 3529 [dict release];
3530 } 3530 }
3531 3531
3532 - (void)testAdds { 3532 - (void)testAdds {
3533 GPBUInt64ObjectDictionary *dict = [GPBUInt64ObjectDictionary dictionary]; 3533 GPBUInt64ObjectDictionary<NSString*> *dict = [GPBUInt64ObjectDictionary dictio nary];
3534 XCTAssertNotNil(dict); 3534 XCTAssertNotNil(dict);
3535 3535
3536 XCTAssertEqual(dict.count, 0U); 3536 XCTAssertEqual(dict.count, 0U);
3537 [dict setObject:@"abc" forKey:31ULL]; 3537 [dict setObject:@"abc" forKey:31ULL];
3538 XCTAssertEqual(dict.count, 1U); 3538 XCTAssertEqual(dict.count, 1U);
3539 3539
3540 const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL }; 3540 const uint64_t kKeys[] = { 32ULL, 33ULL, 34ULL };
3541 const id kObjects[] = { @"def", @"ghi", @"jkl" }; 3541 const NSString* kObjects[] = { @"def", @"ghi", @"jkl" };
3542 GPBUInt64ObjectDictionary *dict2 = 3542 GPBUInt64ObjectDictionary<NSString*> *dict2 =
3543 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects 3543 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
3544 forKeys:kKeys 3544 forKeys:kKeys
3545 count:GPBARRAYSIZE(kObjects)] ; 3545 count:GPBARRAYSIZE(kObjects)] ;
3546 XCTAssertNotNil(dict2); 3546 XCTAssertNotNil(dict2);
3547 [dict addEntriesFromDictionary:dict2]; 3547 [dict addEntriesFromDictionary:dict2];
3548 XCTAssertEqual(dict.count, 4U); 3548 XCTAssertEqual(dict.count, 4U);
3549 3549
3550 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); 3550 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
3551 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); 3551 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
3552 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); 3552 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
3553 XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl"); 3553 XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
3554 [dict2 release]; 3554 [dict2 release];
3555 } 3555 }
3556 3556
3557 - (void)testRemove { 3557 - (void)testRemove {
3558 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL }; 3558 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
3559 const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; 3559 const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
3560 GPBUInt64ObjectDictionary *dict = 3560 GPBUInt64ObjectDictionary<NSString*> *dict =
3561 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects 3561 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
3562 forKeys:kKeys 3562 forKeys:kKeys
3563 count:GPBARRAYSIZE(kObjects)]; 3563 count:GPBARRAYSIZE(kObjects)];
3564 XCTAssertNotNil(dict); 3564 XCTAssertNotNil(dict);
3565 XCTAssertEqual(dict.count, 4U); 3565 XCTAssertEqual(dict.count, 4U);
3566 3566
3567 [dict removeObjectForKey:32ULL]; 3567 [dict removeObjectForKey:32ULL];
3568 XCTAssertEqual(dict.count, 3U); 3568 XCTAssertEqual(dict.count, 3U);
3569 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); 3569 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
3570 XCTAssertNil([dict objectForKey:32ULL]); 3570 XCTAssertNil([dict objectForKey:32ULL]);
(...skipping 19 matching lines...) Expand all
3590 XCTAssertEqual(dict.count, 0U); 3590 XCTAssertEqual(dict.count, 0U);
3591 XCTAssertNil([dict objectForKey:31ULL]); 3591 XCTAssertNil([dict objectForKey:31ULL]);
3592 XCTAssertNil([dict objectForKey:32ULL]); 3592 XCTAssertNil([dict objectForKey:32ULL]);
3593 XCTAssertNil([dict objectForKey:33ULL]); 3593 XCTAssertNil([dict objectForKey:33ULL]);
3594 XCTAssertNil([dict objectForKey:34ULL]); 3594 XCTAssertNil([dict objectForKey:34ULL]);
3595 [dict release]; 3595 [dict release];
3596 } 3596 }
3597 3597
3598 - (void)testInplaceMutation { 3598 - (void)testInplaceMutation {
3599 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL }; 3599 const uint64_t kKeys[] = { 31ULL, 32ULL, 33ULL, 34ULL };
3600 const id kObjects[] = { @"abc", @"def", @"ghi", @"jkl" }; 3600 const NSString* kObjects[] = { @"abc", @"def", @"ghi", @"jkl" };
3601 GPBUInt64ObjectDictionary *dict = 3601 GPBUInt64ObjectDictionary<NSString*> *dict =
3602 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects 3602 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects
3603 forKeys:kKeys 3603 forKeys:kKeys
3604 count:GPBARRAYSIZE(kObjects)]; 3604 count:GPBARRAYSIZE(kObjects)];
3605 XCTAssertNotNil(dict); 3605 XCTAssertNotNil(dict);
3606 XCTAssertEqual(dict.count, 4U); 3606 XCTAssertEqual(dict.count, 4U);
3607 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc"); 3607 XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
3608 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); 3608 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
3609 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); 3609 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
3610 XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl"); 3610 XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
3611 3611
3612 [dict setObject:@"jkl" forKey:31ULL]; 3612 [dict setObject:@"jkl" forKey:31ULL];
3613 XCTAssertEqual(dict.count, 4U); 3613 XCTAssertEqual(dict.count, 4U);
3614 XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl"); 3614 XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl");
3615 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); 3615 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
3616 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); 3616 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
3617 XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl"); 3617 XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
3618 3618
3619 [dict setObject:@"def" forKey:34ULL]; 3619 [dict setObject:@"def" forKey:34ULL];
3620 XCTAssertEqual(dict.count, 4U); 3620 XCTAssertEqual(dict.count, 4U);
3621 XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl"); 3621 XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl");
3622 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def"); 3622 XCTAssertEqualObjects([dict objectForKey:32ULL], @"def");
3623 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi"); 3623 XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
3624 XCTAssertEqualObjects([dict objectForKey:34ULL], @"def"); 3624 XCTAssertEqualObjects([dict objectForKey:34ULL], @"def");
3625 3625
3626 const uint64_t kKeys2[] = { 32ULL, 33ULL }; 3626 const uint64_t kKeys2[] = { 32ULL, 33ULL };
3627 const id kObjects2[] = { @"ghi", @"abc" }; 3627 const NSString* kObjects2[] = { @"ghi", @"abc" };
3628 GPBUInt64ObjectDictionary *dict2 = 3628 GPBUInt64ObjectDictionary<NSString*> *dict2 =
3629 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2 3629 [[GPBUInt64ObjectDictionary alloc] initWithObjects:kObjects2
3630 forKeys:kKeys2 3630 forKeys:kKeys2
3631 count:GPBARRAYSIZE(kObjects2) ]; 3631 count:GPBARRAYSIZE(kObjects2) ];
3632 XCTAssertNotNil(dict2); 3632 XCTAssertNotNil(dict2);
3633 [dict addEntriesFromDictionary:dict2]; 3633 [dict addEntriesFromDictionary:dict2];
3634 XCTAssertEqual(dict.count, 4U); 3634 XCTAssertEqual(dict.count, 4U);
3635 XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl"); 3635 XCTAssertEqualObjects([dict objectForKey:31ULL], @"jkl");
3636 XCTAssertEqualObjects([dict objectForKey:32ULL], @"ghi"); 3636 XCTAssertEqualObjects([dict objectForKey:32ULL], @"ghi");
3637 XCTAssertEqualObjects([dict objectForKey:33ULL], @"abc"); 3637 XCTAssertEqualObjects([dict objectForKey:33ULL], @"abc");
3638 XCTAssertEqualObjects([dict objectForKey:34ULL], @"def"); 3638 XCTAssertEqualObjects([dict objectForKey:34ULL], @"def");
3639 3639
3640 [dict2 release]; 3640 [dict2 release];
3641 [dict release]; 3641 [dict release];
3642 } 3642 }
3643 3643
3644 @end 3644 @end
3645 3645
3646 //%PDDM-EXPAND-END TEST_FOR_POD_KEY(UInt64, uint64_t, 31ULL, 32ULL, 33ULL, 34ULL ) 3646 //%PDDM-EXPAND-END TEST_FOR_POD_KEY(UInt64, uint64_t, 31ULL, 32ULL, 33ULL, 34ULL )
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698