Lines Matching full:message
55 TestAllTypes *message = [TestAllTypes message];
56 [message setOptionalInt32:1];
57 [message setOptionalString:@"foo"];
58 [message setOptionalForeignMessage:[ForeignMessage message]];
59 [message.repeatedStringArray addObject:@"bar"];
60 return message;
64 TestAllTypes *message = [TestAllTypes message];
65 [message setOptionalInt64:2];
66 [message setOptionalString:@"baz"];
67 ForeignMessage *foreignMessage = [ForeignMessage message];
69 [message setOptionalForeignMessage:foreignMessage];
70 [message.repeatedStringArray addObject:@"qux"];
71 return message;
75 TestAllTypes *message = [TestAllTypes message];
76 [message setOptionalInt64:2];
77 [message setOptionalString:@"baz"];
78 [message.repeatedStringArray addObject:@"qux"];
79 return message;
83 TestAllTypes *message = [TestAllTypes message];
84 [message setOptionalInt32:1];
85 [message setOptionalInt64:2];
86 [message setOptionalString:@"foo"];
87 ForeignMessage *foreignMessage = [ForeignMessage message];
89 [message setOptionalForeignMessage:foreignMessage];
90 [message.repeatedStringArray addObject:@"qux"];
91 [message.repeatedStringArray addObject:@"bar"];
92 return message;
96 TestAllTypes *message = [TestAllTypes message];
97 [message setOptionalInt32:1];
98 [message setOptionalInt64:2];
99 [message setOptionalString:@"foo"];
100 ForeignMessage *foreignMessage = [ForeignMessage message];
101 [message setOptionalForeignMessage:foreignMessage];
102 [message.repeatedStringArray addObject:@"qux"];
103 [message.repeatedStringArray addObject:@"bar"];
104 return message;
108 TestAllExtensions *message = [TestAllExtensions message];
109 [message setExtension:[UnittestRoot optionalInt32Extension] value:@5];
110 [message setExtension:[UnittestRoot optionalStringExtension] value:@"foo"];
111 ForeignMessage *foreignMessage = [ForeignMessage message];
113 [message setExtension:[UnittestRoot optionalForeignMessageExtension]
116 [TestAllTypes_NestedMessage message];
117 [message setExtension:[UnittestRoot optionalNestedMessageExtension]
119 return message;
123 TestAllExtensions *message = [TestAllExtensions message];
124 [message setExtension:[UnittestRoot optionalInt64Extension] value:@6];
125 [message setExtension:[UnittestRoot optionalStringExtension] value:@"bar"];
126 ForeignMessage *foreignMessage = [ForeignMessage message];
127 [message setExtension:[UnittestRoot optionalForeignMessageExtension]
130 [TestAllTypes_NestedMessage message];
132 [message setExtension:[UnittestRoot optionalNestedMessageExtension]
134 return message;
138 TestAllExtensions *message = [TestAllExtensions message];
139 [message setExtension:[UnittestRoot optionalInt32Extension] value:@5];
140 [message setExtension:[UnittestRoot optionalInt64Extension] value:@6];
141 [message setExtension:[UnittestRoot optionalStringExtension] value:@"bar"];
142 ForeignMessage *foreignMessage = [ForeignMessage message];
144 [message setExtension:[UnittestRoot optionalForeignMessageExtension]
147 [TestAllTypes_NestedMessage message];
149 [message setExtension:[UnittestRoot optionalNestedMessageExtension]
151 return message;
176 result = [TestAllTypes message];
217 TestRequired *message = [TestRequired message];
218 [message setA:1];
219 [message setB:2];
220 [message setC:3];
221 return message;
225 TestRequired *message = [TestRequired message];
227 XCTAssertFalse(message.initialized);
228 [message setA:1];
229 XCTAssertFalse(message.initialized);
230 [message setB:1];
231 XCTAssertFalse(message.initialized);
232 [message setC:1];
233 XCTAssertTrue(message.initialized);
237 TestRequiredForeign *message = [TestRequiredForeign message];
239 XCTAssertTrue(message.initialized);
241 [message setOptionalMessage:[TestRequired message]];
242 XCTAssertFalse(message.initialized);
244 [message setOptionalMessage:self.testRequiredInitialized];
245 XCTAssertTrue(message.initialized);
247 [message.repeatedMessageArray addObject:[TestRequired message]];
248 XCTAssertFalse(message.initialized);
250 [message.repeatedMessageArray removeAllObjects];
251 [message.repeatedMessageArray addObject:self.testRequiredInitialized];
252 XCTAssertTrue(message.initialized);
256 TestAllExtensions *message = [TestAllExtensions message];
258 XCTAssertTrue(message.initialized);
260 [message setExtension:[TestRequired single] value:[TestRequired message]];
261 XCTAssertFalse(message.initialized);
263 [message setExtension:[TestRequired single]
265 XCTAssertTrue(message.initialized);
267 [message addExtension:[TestRequired multi] value:[TestRequired message]];
268 XCTAssertFalse(message.initialized);
270 [message setExtension:[TestRequired multi]
273 XCTAssertTrue(message.initialized);
277 TestRequired *message = [TestRequired message];
278 NSData *data = [message data];
285 XCTAssertFalse(message.initialized);
291 TestRequired *message = [TestRequired message];
292 XCTAssertFalse(message.initialized);
296 TestRequiredForeign *message = [TestRequiredForeign message];
297 [message setOptionalMessage:[TestRequired message]];
298 [message.repeatedMessageArray addObject:[TestRequired message]];
299 [message.repeatedMessageArray addObject:[TestRequired message]];
300 NSData *data = [message data];
307 XCTAssertFalse(message.initialized);
314 TestRequiredForeign *message = [TestRequiredForeign message];
315 [message setOptionalMessage:[TestRequired message]];
316 [message.repeatedMessageArray addObject:[TestRequired message]];
317 [message.repeatedMessageArray addObject:[TestRequired message]];
319 XCTAssertFalse(message.initialized);
353 TestAllTypes *message = [TestAllTypes message];
354 message.hasOptionalNestedMessage = NO;
355 [message setOptionalNestedMessage:[TestAllTypes_NestedMessage message]];
356 message.hasOptionalNestedMessage = NO;
357 [message setOptionalNestedMessage:[TestAllTypes_NestedMessage message]];
358 [message setOptionalNestedMessage:nil];
359 message.hasOptionalNestedMessage = NO;
363 TestAllTypes *message = [TestAllTypes message];
364 XCTAssertThrows([message setHasOptionalNestedMessage:YES]);
386 TestAllTypes *message = [TestAllTypes message];
387 [self assertClear:message];
391 TestAllTypes *message = [TestAllTypes message];
392 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
393 [self assertAllFieldsSet:message repeatedCount:kGPBDefaultRepeatCount];
397 TestAllTypes *message = [TestAllTypes message];
398 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
399 [self assertAllFieldsKVCMatch:message];
403 TestAllTypes *message = [TestAllTypes message];
404 [self setAllFieldsViaKVC:message repeatedCount:kGPBDefaultRepeatCount];
405 [self assertAllFieldsKVCMatch:message];
406 [self assertAllFieldsSet:message repeatedCount:kGPBDefaultRepeatCount];
407 [self assertAllFieldsKVCMatch:message];
412 TestAllTypes *message = [TestAllTypes message];
413 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
425 [message setUnknownFields:unknownFields];
427 NSString *description = [message description];
430 GPBMessage *message2 = [TestAllExtensions message];
442 // message correctly.
443 TestAllTypes *message = [TestAllTypes message];
444 GPBDescriptor *descriptor = [[message class] descriptor];
450 [message setDefaultInt32:defaultValue.valueInt32];
451 XCTAssertTrue(message.hasDefaultInt32);
452 XCTAssertEqual(message.defaultInt32, defaultValue.valueInt32);
455 message = [TestAllTypes message];
459 [message setDefaultString:defaultValue.valueString];
460 XCTAssertTrue(message.hasDefaultString);
461 XCTAssertEqualObjects(message.defaultString, defaultValue.valueString);
464 message = [TestAllTypes message];
465 XCTAssertEqualObjects(message.defaultString, @"hello");
466 XCTAssertFalse(message.hasDefaultString);
470 [message setDefaultString:defaultValue.valueString];
471 XCTAssertEqualObjects(message.defaultString, @"hello");
472 XCTAssertTrue(message.hasDefaultString);
473 [message setDefaultString:nil];
474 XCTAssertEqualObjects(message.defaultString, @"hello");
475 XCTAssertFalse(message.hasDefaultString);
476 message.hasDefaultString = NO;
477 XCTAssertFalse(message.hasDefaultString);
478 XCTAssertEqualObjects(message.defaultString, @"hello");
482 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
483 XCTAssertFalse(message.hasDefaultString);
487 [message setDefaultBytes:defaultValue.valueData];
488 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
489 XCTAssertTrue(message.hasDefaultBytes);
490 [message setDefaultBytes:nil];
491 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
492 XCTAssertFalse(message.hasDefaultBytes);
493 message.hasDefaultBytes = NO;
494 XCTAssertFalse(message.hasDefaultBytes);
495 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
498 XCTAssertFalse(message.hasOptionalString);
499 XCTAssertEqualObjects(message.optionalString, @"");
500 XCTAssertFalse(message.hasOptionalString);
501 message.optionalString = nil;
502 XCTAssertFalse(message.hasOptionalString);
503 XCTAssertEqualObjects(message.optionalString, @"");
505 message.optionalString = string;
506 XCTAssertEqualObjects(message.optionalString, string);
507 XCTAssertTrue(message.hasOptionalString);
508 message.optionalString = nil;
509 XCTAssertFalse(message.hasOptionalString);
510 XCTAssertEqualObjects(message.optionalString, @"");
513 XCTAssertFalse(message.hasOptionalBytes);
514 XCTAssertEqualObjects(message.optionalBytes, GPBEmptyNSData());
515 XCTAssertFalse(message.hasOptionalBytes);
516 message.optionalBytes = nil;
517 XCTAssertFalse(message.hasOptionalBytes);
518 XCTAssertEqualObjects(message.optionalBytes, GPBEmptyNSData());
520 message.optionalBytes = data;
521 XCTAssertEqualObjects(message.optionalBytes, data);
522 XCTAssertTrue(message.hasOptionalBytes);
523 message.optionalBytes = nil;
524 XCTAssertFalse(message.hasOptionalBytes);
525 XCTAssertEqualObjects(message.optionalBytes, GPBEmptyNSData());
527 // Test lazy message setting
528 XCTAssertFalse(message.hasOptionalLazyMessage);
529 XCTAssertNotNil(message.optionalLazyMessage);
530 XCTAssertFalse(message.hasOptionalLazyMessage);
531 message.hasOptionalLazyMessage = NO;
532 XCTAssertFalse(message.hasOptionalLazyMessage);
533 XCTAssertNotNil(message.optionalLazyMessage);
534 XCTAssertFalse(message.hasOptionalLazyMessage);
535 message.optionalLazyMessage = nil;
536 XCTAssertFalse(message.hasOptionalLazyMessage);
539 XCTAssertFalse(message.hasOptionalLazyMessage);
540 message.optionalLazyMessage.bb = 1;
541 XCTAssertTrue(message.hasOptionalLazyMessage);
542 XCTAssertEqual(message.optionalLazyMessage.bb, 1);
543 XCTAssertNotNil(message.optionalLazyMessage);
544 message.optionalLazyMessage = nil;
545 XCTAssertFalse(message.hasOptionalLazyMessage);
546 XCTAssertEqual(message.optionalLazyMessage.bb, 0);
547 XCTAssertFalse(message.hasOptionalLazyMessage);
548 XCTAssertNotNil(message.optionalLazyMessage);
555 TestAllTypes *message = [TestAllTypes message];
556 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
557 [self modifyRepeatedFields:message];
558 [self assertRepeatedFieldsModified:message
563 TestAllTypes *message = [TestAllTypes message];
564 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
565 [self clearAllFields:message];
566 [self assertClear:message];
567 TestAllTypes *message2 = [TestAllTypes message];
568 XCTAssertEqualObjects(message, message2);
572 TestAllTypes *message = [TestAllTypes message];
573 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
574 [self clearAllFields:message];
575 [self assertClear:message];
576 [self assertClearKVC:message];
581 GPBMessage *message1 = [TestAllExtensions message];
588 GPBMessage *message2 = [TestAllExtensions message];
599 // Clearing an unset extension field shouldn't make the target message
601 GPBMessage *message3 = [TestAllExtensions message];
610 TestAllTypes *message = [TestAllTypes message];
614 XCTAssertFalse(message.hasOptionalGroup);
615 XCTAssertFalse(message.hasOptionalNestedMessage);
616 XCTAssertFalse(message.hasOptionalForeignMessage);
617 XCTAssertFalse(message.hasOptionalImportMessage);
618 XCTAssertFalse(message.hasOptionalPublicImportMessage);
619 XCTAssertFalse(message.hasOptionalLazyMessage);
623 TestAllTypes_OptionalGroup *optionalGroup = [message.optionalGroup retain];
625 [message.optionalNestedMessage retain];
627 [message.optionalForeignMessage retain];
628 ImportMessage *optionalImportMessage = [message.optionalImportMessage retain];
630 [message.optionalPublicImportMessage retain];
632 [message.optionalLazyMessage retain];
644 XCTAssertFalse(message.hasOptionalGroup);
645 XCTAssertFalse(message.hasOptionalNestedMessage);
646 XCTAssertFalse(message.hasOptionalForeignMessage);
647 XCTAssertFalse(message.hasOptionalImportMessage);
648 XCTAssertFalse(message.hasOptionalPublicImportMessage);
649 XCTAssertFalse(message.hasOptionalLazyMessage);
651 // And they set that value back in to the message since the value created was
654 XCTAssertEqual(message.optionalGroup, optionalGroup);
655 XCTAssertEqual(message.optionalNestedMessage, optionalNestedMessage);
656 XCTAssertEqual(message.optionalForeignMessage, optionalForeignMessage);
657 XCTAssertEqual(message.optionalImportMessage, optionalImportMessage);
658 XCTAssertEqual(message.optionalPublicImportMessage,
660 XCTAssertEqual(message.optionalLazyMessage, optionalLazyMessage);
662 // And the default objects for a second message should be distinct (again,
665 TestAllTypes *message2 = [TestAllTypes message];
679 message.optionalGroup = nil;
680 message.optionalNestedMessage = nil;
681 message.optionalForeignMessage = nil;
682 message.optionalImportMessage = nil;
683 message.optionalPublicImportMessage = nil;
684 message.optionalLazyMessage = nil;
686 XCTAssertFalse(message.hasOptionalGroup);
687 XCTAssertFalse(message.hasOptionalNestedMessage);
688 XCTAssertFalse(message.hasOptionalForeignMessage);
689 XCTAssertFalse(message.hasOptionalImportMessage);
690 XCTAssertFalse(message.hasOptionalPublicImportMessage);
691 XCTAssertFalse(message.hasOptionalLazyMessage);
694 XCTAssertNotEqual(message.optionalGroup, optionalGroup);
695 XCTAssertNotEqual(message.optionalNestedMessage, optionalNestedMessage);
696 XCTAssertNotEqual(message.optionalForeignMessage, optionalForeignMessage);
697 XCTAssertNotEqual(message.optionalImportMessage, optionalImportMessage);
698 XCTAssertNotEqual(message.optionalPublicImportMessage,
700 XCTAssertNotEqual(message.optionalLazyMessage, optionalLazyMessage);
711 // Multiple objects pointing to the same autocreated message.
712 TestAllTypes *message = [TestAllTypes message];
713 TestAllTypes *message2 = [TestAllTypes message];
714 message2.optionalGroup = message.optionalGroup;
716 XCTAssertFalse([message hasOptionalGroup]);
718 XCTAssertTrue([message hasOptionalGroup]);
724 TestAllTypes *message = [TestAllTypes message];
725 message.optionalGroup.a = 42;
726 XCTAssertNotNil(message.optionalNestedMessage);
727 TestAllTypes *message2 = [[message copy] autorelease];
732 XCTAssertNotEqual(message.optionalNestedMessage,
739 TestRecursiveMessage *message = [TestRecursiveMessage message];
740 TestRecursiveMessage *message_inner = [message.a.a.a retain];
742 XCTAssertTrue(GPBWasMessageAutocreatedBy(message_inner, message.a.a));
743 [message.a.a clear];
744 XCTAssertFalse(GPBWasMessageAutocreatedBy(message_inner, message.a.a));
747 XCTAssertNotEqual(message.a.a.a, message_inner);
754 TestAllTypes *message = [TestAllTypes message];
758 TestAllTypes *message2 = [TestAllTypes message];
760 message.optionalForeignMessage = subMessage;
761 XCTAssertTrue(GPBWasMessageAutocreatedBy(message.optionalForeignMessage,
766 XCTAssertEqual(message.optionalForeignMessage, subMessage);
771 TestRecursiveMessage *message = [TestRecursiveMessage message];
772 TestRecursiveMessage *message_inner = [message.a.a retain];
773 XCTAssertFalse([message hasA]);
774 XCTAssertFalse([message.a hasA]);
775 message.a.a = nil;
777 // |message.a| has to be made visible, but |message.a.a| was set to nil so
779 XCTAssertTrue([message hasA]);
780 XCTAssertFalse([message.a hasA]);
783 XCTAssertFalse(GPBWasMessageAutocreatedBy(message_inner, message.a));
786 // message.
788 XCTAssertNotEqual(message.a.a, message_inner);
796 TestAllTypes *message = [TestAllTypes message];
797 TestAllTypes_NestedMessage *nestedMessage = message.optionalNestedMessage;
798 XCTAssertFalse([message hasOptionalNestedMessage]);
799 [message setHasOptionalNestedMessage:NO];
800 XCTAssertFalse([message hasOptionalNestedMessage]);
801 XCTAssertEqual(message.optionalNestedMessage, nestedMessage);
807 TestRecursiveMessage *message = [TestRecursiveMessage message];
808 message.a.a.a.a.i = 42;
809 XCTAssertTrue([message hasA]);
810 XCTAssertTrue([message.a hasA]);
811 XCTAssertTrue([message.a.a hasA]);
812 XCTAssertTrue([message.a.a.a hasA]);
813 XCTAssertFalse([message.a.a.a.a hasA]);
814 XCTAssertEqual(message.a.a.a.a.i, 42);
820 TestRecursiveMessage *message = [TestRecursiveMessage message];
821 message.a.a.a.a.hasI = NO;
822 XCTAssertFalse([message hasA]);
823 XCTAssertFalse([message.a hasA]);
824 XCTAssertFalse([message.a.a hasA]);
825 XCTAssertFalse([message.a.a.a hasA]);
829 TestRecursiveMessage *message = [TestRecursiveMessage message];
830 TestRecursiveMessage *messageLevel1 = [message.a retain];
831 TestRecursiveMessage *messageLevel2 = [message.a.a retain];
832 TestRecursiveMessage *messageLevel3 = [message.a.a.a retain];
833 TestRecursiveMessage *messageLevel4 = [message.a.a.a.a retain];
834 XCTAssertTrue(GPBWasMessageAutocreatedBy(messageLevel1, message));
840 message.a = message.a.a;
841 XCTAssertEqual(message.a, messageLevel2);
842 XCTAssertTrue([message hasA]);
843 XCTAssertEqual(message.a.a, messageLevel3);
844 XCTAssertFalse([message.a hasA]);
845 XCTAssertEqual(message.a.a.a, messageLevel4);
847 message)); // Because it was orphaned.
858 TestRecursiveMessage *message = [TestRecursiveMessage message];
859 TestRecursiveMessage *messageLevel1 = [message.a retain];
860 TestRecursiveMessage *messageLevel2 = [message.a.a retain];
861 TestRecursiveMessage *messageLevel3 = [message.a.a.a retain];
862 TestRecursiveMessage *messageLevel4 = [message.a.a.a.a retain];
863 XCTAssertTrue(GPBWasMessageAutocreatedBy(messageLevel1, message));
870 message.a.a = message.a;
871 XCTAssertTrue([message hasA]);
872 XCTAssertEqual(message.a, messageLevel1);
873 XCTAssertTrue([message.a hasA]);
874 XCTAssertEqual(message.a.a, messageLevel1);
875 XCTAssertTrue([message.a.a hasA]);
876 XCTAssertEqual(message.a.a.a, messageLevel1);
878 message)); // Because it was assigned.
884 message.a.a = nil;
885 XCTAssertTrue([message hasA]);
886 XCTAssertFalse([message.a hasA]);
897 TestAllTypes *message = [TestAllTypes message];
899 [message.optionalNestedMessage retain];
901 message.optionalNestedMessage = [TestAllTypes_NestedMessage message];
902 XCTAssertTrue([message hasOptionalNestedMessage]);
903 XCTAssertTrue(message.optionalNestedMessage != nestedMessage);
904 XCTAssertFalse(GPBWasMessageAutocreatedBy(nestedMessage, message));
912 TestAllTypes *message = [TestAllTypes message];
913 XCTAssertNotNil(message.optionalNestedMessage);
914 XCTAssertFalse([message hasOptionalNestedMessage]);
915 XCTAssertNil(message.optionalNestedMessage.unknownFields);
916 XCTAssertFalse([message hasOptionalNestedMessage]);
920 message.optionalNestedMessage.unknownFields = unknownFields;
921 XCTAssertTrue([message hasOptionalNestedMessage]);
923 message.optionalNestedMessage = nil;
924 XCTAssertFalse([message hasOptionalNestedMessage]);
925 [message.optionalNestedMessage setUnknownFields:unknownFields];
926 XCTAssertTrue([message hasOptionalNestedMessage]);
931 TestAllTypes *message = [TestAllTypes message];
932 XCTAssertNotNil(message.optionalNestedMessage);
933 XCTAssertFalse([message hasOptionalNestedMessage]);
934 message.optionalNestedMessage = message.optionalNestedMessage;
935 XCTAssertTrue([message hasOptionalNestedMessage]);
940 TestRecursiveMessage *message;
946 message = [[TestRecursiveMessage alloc] init];
947 messageLevel1 = [message.a retain];
948 messageLevel2 = [message.a.a retain];
949 messageLevel3 = [message.a.a.a retain];
950 messageLevel4 = [message.a.a.a.a retain];
951 message.a.i = 1;
954 XCTAssertEqual(message.retainCount, (NSUInteger)1);
955 [message release];
967 // Basic tests for default creation of arrays in a message.
968 TestRecursiveMessageWithRepeatedField *message =
969 [TestRecursiveMessageWithRepeatedField message];
971 [TestRecursiveMessageWithRepeatedField message];
974 XCTAssertNotNil(message.a.a.iArray);
975 XCTAssertFalse([message hasA]);
976 XCTAssertFalse([message.a hasA]);
982 [message.a.a.iArray addValue:42];
983 XCTAssertTrue([message hasA]);
984 XCTAssertTrue([message.a hasA]);
985 XCTAssertEqual([message.a.a.iArray count], (NSUInteger)1);
995 [TestRecursiveMessageWithRepeatedField message];
997 [TestRecursiveMessageWithRepeatedField message];
1007 [TestRecursiveMessageWithRepeatedField message];
1009 [TestRecursiveMessageWithRepeatedField message];
1021 TestAllTypes *message = [TestAllTypes message];
1022 XCTAssertNotNil(message.repeatedStringArray);
1023 XCTAssertNotNil(message.repeatedInt32Array);
1024 TestAllTypes *message2 = [[message copy] autorelease];
1026 XCTAssertNotEqual(message.repeatedStringArray, message2.repeatedStringArray);
1027 XCTAssertNotEqual(message.repeatedInt32Array, message2.repeatedInt32Array);
1031 TestAllTypes *message3 = [TestAllTypes message];
1034 XCTAssertNotNil(message.repeatedInt32Array);
1035 XCTAssertNotNil(message.repeatedStringArray);
1047 TestAllTypes *message = [TestAllTypes message];
1050 TestAllTypes *message2 = [TestAllTypes message];
1051 message.repeatedInt32Array = message2.repeatedInt32Array;
1052 message.repeatedStringArray = message2.repeatedStringArray;
1054 XCTAssertEqual(message.repeatedInt32Array->_autocreator, message2);
1055 XCTAssertTrue([message.repeatedStringArray
1058 ((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator,
1062 XCTAssertNil(message.repeatedInt32Array->_autocreator);
1064 [message.repeatedStringArray isKindOfClass:[GPBAutocreatedArray class]]);
1066 ((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator);
1071 TestAllTypes *message = [TestAllTypes message];
1072 GPBInt32Array *repeatedInt32Array = [message.repeatedInt32Array retain];
1074 (GPBAutocreatedArray *)[message.repeatedStringArray retain];
1076 XCTAssertEqual(repeatedInt32Array->_autocreator, message);
1077 XCTAssertEqual(repeatedStringArray->_autocreator, message);
1078 message.repeatedInt32Array = nil;
1079 message.repeatedStringArray = nil;
1091 TestAllTypes *message = [TestAllTypes message];
1092 [message.repeatedStringArray addObject:@"foo"];
1093 XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
1094 message.repeatedStringArray = [NSMutableArray arrayWithObjects:@"bar", @"bar2", nil];
1095 XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)2);
1096 message.repeatedStringArray = [NSMutableArray arrayWithObject:@"baz"];
1097 XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
1104 TestRecursiveMessageWithRepeatedField *message =
1105 [TestRecursiveMessageWithRepeatedField message];
1106 XCTAssertNotNil(message.a);
1107 XCTAssertNotNil(message.a.iArray);
1108 XCTAssertFalse([message hasA]);
1109 GPBInt32Array *iArray = [message.a.iArray retain];
1110 XCTAssertEqual(iArray->_autocreator, message.a); // Pointer comparision
1111 message.a.iArray = [GPBInt32Array arrayWithValue:1];
1112 XCTAssertTrue([message hasA]);
1113 XCTAssertNotEqual(message.a.iArray, iArray); // Pointer comparision
1119 TestRecursiveMessageWithRepeatedField *message =
1120 [TestRecursiveMessageWithRepeatedField message];
1121 XCTAssertNotNil(message.a);
1122 XCTAssertNotNil(message.a.strArray);
1123 XCTAssertFalse([message hasA]);
1125 (GPBAutocreatedArray *)[message.a.strArray retain];
1127 XCTAssertEqual(strArray->_autocreator, message.a); // Pointer comparision
1128 message.a.strArray = [NSMutableArray arrayWithObject:@"foo"];
1129 XCTAssertTrue([message hasA]);
1130 XCTAssertNotEqual(message.a.strArray, strArray); // Pointer comparision
1139 TestRecursiveMessageWithRepeatedField *message =
1140 [TestRecursiveMessageWithRepeatedField message];
1141 XCTAssertNotNil(message.a);
1142 XCTAssertNotNil(message.a.iArray);
1143 XCTAssertFalse([message hasA]);
1144 message.a.iArray = message.a.iArray;
1145 XCTAssertTrue([message hasA]);
1146 XCTAssertNil(message.a.iArray->_autocreator);
1150 TestRecursiveMessageWithRepeatedField *message =
1151 [TestRecursiveMessageWithRepeatedField message];
1152 XCTAssertNotNil(message.a);
1153 XCTAssertNotNil(message.a.strArray);
1154 XCTAssertFalse([message hasA]);
1155 message.a.strArray = message.a.strArray;
1156 XCTAssertTrue([message hasA]);
1157 XCTAssertTrue([message.a.strArray isKindOfClass:[GPBAutocreatedArray class]]);
1158 XCTAssertNil(((GPBAutocreatedArray *)message.a.strArray)->_autocreator);
1165 TestRecursiveMessageWithRepeatedField *message =
1166 [TestRecursiveMessageWithRepeatedField message];
1167 [message.a.iArray removeAll];
1168 XCTAssertFalse([message hasA]);
1169 [message.a.strArray removeAllObjects];
1170 XCTAssertFalse([message hasA]);
1174 // Basic tests for default creation of maps in a message.
1175 TestRecursiveMessageWithRepeatedField *message =
1176 [TestRecursiveMessageWithRepeatedField message];
1178 [TestRecursiveMessageWithRepeatedField message];
1181 XCTAssertNotNil(message.a.a.iToI);
1182 XCTAssertFalse([message hasA]);
1183 XCTAssertFalse([message.a hasA]);
1189 [message.a.a.iToI setInt32:100 forKey:200];
1190 XCTAssertTrue([message hasA]);
1191 XCTAssertTrue([message.a hasA]);
1192 XCTAssertEqual([message.a.a.iToI count], (NSUInteger)1);
1202 [TestRecursiveMessageWithRepeatedField message];
1204 [TestRecursiveMessageWithRepeatedField message];
1214 [TestRecursiveMessageWithRepeatedField message];
1216 [TestRecursiveMessageWithRepeatedField message];
1228 TestRecursiveMessageWithRepeatedField *message =
1229 [TestRecursiveMessageWithRepeatedField message];
1230 XCTAssertNotNil(message.strToStr);
1231 XCTAssertNotNil(message.iToI);
1233 [[message copy] autorelease];
1235 XCTAssertNotEqual(message.strToStr, message2.strToStr);
1236 XCTAssertNotEqual(message.iToI, message2.iToI);
1241 [TestRecursiveMessageWithRepeatedField message];
1246 XCTAssertNotNil(message.iToI);
1247 XCTAssertNotNil(message.iToI);
1258 TestRecursiveMessageWithRepeatedField *message =
1259 [TestRecursiveMessageWithRepeatedField message];
1263 [TestRecursiveMessageWithRepeatedField message];
1264 message.iToI = message2.iToI;
1265 message.strToStr = message2.strToStr;
1267 XCTAssertEqual(message.iToI->_autocreator, message2);
1268 XCTAssertTrue([message.strToStr
1271 ((GPBAutocreatedDictionary *)message.strToStr)->_autocreator,
1275 XCTAssertNil(message.iToI->_autocreator);
1277 [message.strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
1279 ((GPBAutocreatedDictionary *)message.strToStr)->_autocreator);
1284 TestRecursiveMessageWithRepeatedField *message =
1285 [TestRecursiveMessageWithRepeatedField message];
1286 GPBInt32Int32Dictionary *iToI = [message.iToI retain];
1288 (GPBAutocreatedDictionary *)[message.strToStr retain];
1290 XCTAssertEqual(iToI->_autocreator, message);
1291 XCTAssertEqual(strToStr->_autocreator, message);
1292 message.iToI = nil;
1293 message.strToStr = nil;
1305 TestRecursiveMessageWithRepeatedField *message =
1306 [TestRecursiveMessageWithRepeatedField message];
1307 message.strToStr[@"foo"] = @"bar";
1308 XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
1309 message.strToStr =
1311 XCTAssertEqual(message.strToStr_Count, (NSUInteger)2);
1312 message.strToStr =
1314 XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
1321 TestRecursiveMessageWithRepeatedField *message =
1322 [TestRecursiveMessageWithRepeatedField message];
1323 XCTAssertNotNil(message.a);
1324 XCTAssertNotNil(message.a.iToI);
1325 XCTAssertFalse([message hasA]);
1326 GPBInt32Int32Dictionary *iToI = [message.a.iToI retain];
1327 XCTAssertEqual(iToI->_autocreator, message.a); // Pointer comparision
1328 message.a.iToI = [[[GPBInt32Int32Dictionary alloc] init] autorelease];
1329 [message.a.iToI setInt32:6 forKey:7];
1330 XCTAssertTrue([message hasA]);
1331 XCTAssertNotEqual(message.a.iToI, iToI); // Pointer comparision
1337 TestRecursiveMessageWithRepeatedField *message =
1338 [TestRecursiveMessageWithRepeatedField message];
1339 XCTAssertNotNil(message.a);
1340 XCTAssertNotNil(message.a.strToStr);
1341 XCTAssertFalse([message hasA]);
1343 (GPBAutocreatedDictionary *)[message.a.strToStr retain];
1345 XCTAssertEqual(strToStr->_autocreator, message.a); // Pointer comparision
1346 message.a.strToStr =
1348 XCTAssertTrue([message hasA]);
1349 XCTAssertNotEqual(message.a.strToStr, strToStr); // Pointer comparision
1358 TestRecursiveMessageWithRepeatedField *message =
1359 [TestRecursiveMessageWithRepeatedField message];
1360 XCTAssertNotNil(message.a);
1361 XCTAssertNotNil(message.a.iToI);
1362 XCTAssertFalse([message hasA]);
1363 message.a.iToI = message.a.iToI;
1364 XCTAssertTrue([message hasA]);
1365 XCTAssertNil(message.a.iToI->_autocreator);
1369 TestRecursiveMessageWithRepeatedField *message =
1370 [TestRecursiveMessageWithRepeatedField message];
1371 XCTAssertNotNil(message.a);
1372 XCTAssertNotNil(message.a.strToStr);
1373 XCTAssertFalse([message hasA]);
1374 message.a.strToStr = message.a.strToStr;
1375 XCTAssertTrue([message hasA]);
1376 XCTAssertTrue([message.a.strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
1377 XCTAssertNil(((GPBAutocreatedDictionary *)message.a.strToStr)->_autocreator);
1383 TestRecursiveMessageWithRepeatedField *message =
1384 [TestRecursiveMessageWithRepeatedField message];
1385 [message.a.iToI removeAll];
1386 XCTAssertFalse([message hasA]);
1387 [message.a.strToStr removeAllObjects];
1388 XCTAssertFalse([message hasA]);
1392 TestAllExtensions *message = [TestAllExtensions message];
1393 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1394 [self assertAllExtensionsSet:message repeatedCount:kGPBDefaultRepeatCount];
1398 TestAllExtensions *message = [TestAllExtensions message];
1399 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1400 [self modifyRepeatedExtensions:message];
1401 [self assertRepeatedExtensionsModified:message
1406 [self assertExtensionsClear:[TestAllExtensions message]];
1410 TestAllExtensions *message = [TestAllExtensions message];
1411 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1412 [self modifyRepeatedExtensions:message];
1413 TestAllExtensions *message2 = [TestAllExtensions message];
1415 XCTAssertFalse([message isEqual:message2]);
1416 message2 = [TestAllExtensions message];
1419 XCTAssertEqualObjects(message, message2);
1423 TestAllExtensions *message = [TestAllExtensions message];
1424 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1425 [self modifyRepeatedExtensions:message];
1427 message = [TestAllExtensions message];
1428 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1429 TestAllExtensions *message2 = [TestAllExtensions message];
1431 [message2 mergeFrom:message];
1433 XCTAssertEqualObjects(message, message2);
1437 TestAllExtensions *message = [TestAllExtensions message];
1441 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1442 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1444 [message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
1446 [message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
1448 [message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
1449 XCTAssertFalse([message
1452 [message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
1457 [message getExtension:[UnittestRoot optionalGroupExtension]];
1459 [message getExtension:[UnittestRoot optionalNestedMessageExtension]];
1461 [message getExtension:[UnittestRoot optionalForeignMessageExtension]];
1463 [message getExtension:[UnittestRoot optionalImportMessageExtension]];
1464 PublicImportMessage *optionalPublicImportMessage = [message
1467 [message getExtension:[UnittestRoot optionalLazyMessageExtension]];
1479 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1480 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1481 XCTAssertFalse([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
1482 XCTAssertFalse([message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
1483 XCTAssertFalse([message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
1484 XCTAssertFalse([message hasExtension:[UnittestRoot optionalPublicImportMessageExtension]]);
1485 XCTAssertFalse([message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
1487 // And they set that value back in to the message since the value created was
1490 XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]],
1493 [message getExtension:[UnittestRoot optionalNestedMessageExtension]],
1496 [message getExtension:[UnittestRoot optionalForeignMessageExtension]],
1499 [message getExtension:[UnittestRoot optionalImportMessageExtension]],
1502 [message getExtension:[UnittestRoot optionalPublicImportMessageExtension]],
1505 [message getExtension:[UnittestRoot optionalLazyMessageExtension]],
1508 // And the default objects for a second message should be distinct (again,
1511 TestAllExtensions *message2 = [TestAllExtensions message];
1535 [message setExtension:[UnittestRoot optionalGroupExtension] value:nil];
1536 [message setExtension:[UnittestRoot optionalGroupExtension] value:nil];
1537 [message setExtension:[UnittestRoot optionalNestedMessageExtension]
1539 [message setExtension:[UnittestRoot optionalForeignMessageExtension]
1541 [message setExtension:[UnittestRoot optionalImportMessageExtension]
1543 [message setExtension:[UnittestRoot optionalPublicImportMessageExtension]
1545 [message setExtension:[UnittestRoot optionalLazyMessageExtension] value:nil];
1547 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1548 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1550 [message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
1552 [message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
1554 [message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
1555 XCTAssertFalse([message
1558 [message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
1560 XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]],
1563 [message getExtension:[UnittestRoot optionalNestedMessageExtension]],
1566 [message getExtension:[UnittestRoot optionalForeignMessageExtension]],
1569 [message getExtension:[UnittestRoot optionalImportMessageExtension]],
1572 [message
1576 [message getExtension:[UnittestRoot optionalLazyMessageExtension]],
1583 TestAllExtensions *message = [TestAllExtensions message];
1584 TestAllExtensions *message2 = [TestAllExtensions message];
1586 [message setExtension:extension value:[message2 getExtension:extension]];
1587 XCTAssertEqual([message getExtension:extension],
1590 XCTAssertTrue([message hasExtension:extension]);
1596 XCTAssertTrue([message hasExtension:extension]);
1601 TestAllExtensions *message = [TestAllExtensions message];
1607 [message getExtension:optionalGroupExtension];
1610 XCTAssertNotNil([message getExtension:optionalNestedMessageExtesion]);
1611 XCTAssertTrue([message hasExtension:optionalGroupExtension]);
1612 XCTAssertFalse([message hasExtension:optionalNestedMessageExtesion]);
1614 TestAllExtensions *message2 = [[message copy] autorelease];
1618 XCTAssertEqualObjects([message getExtension:optionalGroupExtension],
1621 XCTAssertNotEqual([message getExtension:optionalGroupExtension],
1627 XCTAssertNotEqual([message getExtension:optionalNestedMessageExtesion],
1633 TestAllExtensions *message = [TestAllExtensions message];
1637 [[message getExtension:optionalGroupExtension] retain];
1638 [message clear];
1640 [message getExtension:optionalGroupExtension];
1650 TestAllExtensions *message = [TestAllExtensions message];
1655 TestAllExtensions *message2 = [TestAllExtensions message];
1656 [message setExtension:optionalGroupExtension
1659 [message getExtension:optionalGroupExtension], message2));
1663 [message getExtension:optionalGroupExtension], message));
1668 TestAllExtensions *message = [TestAllExtensions message];
1672 [[message getExtension:optionalGroupExtension] retain];
1673 [message clearExtension:optionalGroupExtension];
1675 [message getExtension:optionalGroupExtension];
1677 XCTAssertFalse([message hasExtension:optionalGroupExtension]);
1684 TestAllExtensions *message_lvl2 = [message getExtension:recursiveExtension];
1688 XCTAssertFalse([message hasExtension:recursiveExtension]);
1694 TestAllExtensions *message = [TestAllExtensions message];
1697 TestAllExtensions *message_lvl2 = [message getExtension:recursiveExtension];
1702 XCTAssertFalse([message hasExtension:recursiveExtension]);
1707 XCTAssertTrue([message hasExtension:recursiveExtension]);
1713 XCTAssertFalse(GPBWasMessageAutocreatedBy(message_lvl2, message));
1718 TestAllExtensions *message = [TestAllExtensions message];
1721 XCTAssertNotNil([message getExtension:optionalGroupExtension]);
1722 XCTAssertFalse([message hasExtension:optionalGroupExtension]);
1723 [message setExtension:optionalGroupExtension
1724 value:[message getExtension:optionalGroupExtension]];
1725 XCTAssertTrue([message hasExtension:optionalGroupExtension]);
1733 TestAllExtensions *message;
1738 message = [[TestAllExtensions alloc] init];
1739 message_lvl2 = [[message getExtension:recursiveExtension] retain];
1746 XCTAssertEqual(message.retainCount, (NSUInteger)1);
1748 [message release];
1766 TestAllExtensions *message;
1768 message = [[TestAllExtensions alloc] init];
1769 [message getExtension:recursiveExtension];
1774 [message setExtension:recursiveExtension
1775 value:[message getExtension:recursiveExtension]];
1776 XCTAssertTrue([message hasExtension:recursiveExtension]);
1777 [message release];
1781 TestRecursiveMessage *message = [TestRecursiveMessage message];
1782 XCTAssertNotNil(message.a);
1783 XCTAssertNotNil(message.a.a);
1784 XCTAssertEqual(message.a.a.i, 0);
1791 GPBMessage *message = [GPBMessage message];
1792 [message setUnknownFields:unknowns];
1793 NSData *data = [message data];
1796 XCTAssertEqualObjects(message, message2);
1803 GPBMessage *message1 = [GPBMessage message];
1810 GPBMessage *message2 = [GPBMessage message];
1833 ObjcWeirdDefaults *message = [ObjcWeirdDefaults message];
1834 GPBDescriptor *descriptor = [[message class] descriptor];
1838 XCTAssertFalse(message.hasFoo);
1839 XCTAssertEqualObjects(message.foo, @"");
1844 XCTAssertFalse(message.hasBar);
1845 XCTAssertEqualObjects(message.bar, GPBEmptyNSData());
1863 ObjCPropertyNaming *msg = [ObjCPropertyNaming message];
1926 EnumTestMsg *msg = [EnumTestMsg message];
1991 self_Class *msg = [self_Class message];
2031 // Message with no explicit defaults, but a non zero default for an enum.
2032 MessageWithOneBasedEnum *enumMsg = [MessageWithOneBasedEnum message];
2040 BoolOnlyMessage *msg1 = [BoolOnlyMessage message];
2041 BoolOnlyMessage *msg2 = [BoolOnlyMessage message];
2102 TestMessageOfMaps *msg = [TestMessageOfMaps message];
2117 TestAllTypes *subMsg1 = [TestAllTypes message];
2119 TestAllTypes *subMsg2 = [TestAllTypes message];
2121 TestAllTypes *subMsg3 = [TestAllTypes message];