• Home
  • Raw
  • Download

Lines Matching refs: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);
377 TestAllTypes *message = [TestAllTypes message];
378 message.hasOptionalNestedMessage = NO;
379 [message setOptionalNestedMessage:[TestAllTypes_NestedMessage message]];
380 message.hasOptionalNestedMessage = NO;
381 [message setOptionalNestedMessage:[TestAllTypes_NestedMessage message]];
382 [message setOptionalNestedMessage:nil];
383 message.hasOptionalNestedMessage = NO;
387 TestAllTypes *message = [TestAllTypes message];
388 XCTAssertThrows([message setHasOptionalNestedMessage:YES]);
410 TestAllTypes *message = [TestAllTypes message];
411 [self assertClear:message];
415 TestAllTypes *message = [TestAllTypes message];
416 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
417 [self assertAllFieldsSet:message repeatedCount:kGPBDefaultRepeatCount];
421 TestAllTypes *message = [TestAllTypes message];
422 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
423 [self assertAllFieldsKVCMatch:message];
427 TestAllTypes *message = [TestAllTypes message];
428 [self setAllFieldsViaKVC:message repeatedCount:kGPBDefaultRepeatCount];
429 [self assertAllFieldsKVCMatch:message];
430 [self assertAllFieldsSet:message repeatedCount:kGPBDefaultRepeatCount];
431 [self assertAllFieldsKVCMatch:message];
436 TestAllTypes *message = [TestAllTypes message];
437 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
449 [message setUnknownFields:unknownFields];
451 NSString *description = [message description];
454 GPBMessage *message2 = [TestAllExtensions message];
466 // message correctly.
467 TestAllTypes *message = [TestAllTypes message];
468 GPBDescriptor *descriptor = [[message class] descriptor];
474 [message setDefaultInt32:defaultValue.valueInt32];
475 XCTAssertTrue(message.hasDefaultInt32);
476 XCTAssertEqual(message.defaultInt32, defaultValue.valueInt32);
479 message = [TestAllTypes message];
483 [message setDefaultString:defaultValue.valueString];
484 XCTAssertTrue(message.hasDefaultString);
485 XCTAssertEqualObjects(message.defaultString, defaultValue.valueString);
488 message = [TestAllTypes message];
489 XCTAssertEqualObjects(message.defaultString, @"hello");
490 XCTAssertFalse(message.hasDefaultString);
494 [message setDefaultString:defaultValue.valueString];
495 XCTAssertEqualObjects(message.defaultString, @"hello");
496 XCTAssertTrue(message.hasDefaultString);
497 [message setDefaultString:nil];
498 XCTAssertEqualObjects(message.defaultString, @"hello");
499 XCTAssertFalse(message.hasDefaultString);
500 message.hasDefaultString = NO;
501 XCTAssertFalse(message.hasDefaultString);
502 XCTAssertEqualObjects(message.defaultString, @"hello");
506 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
507 XCTAssertFalse(message.hasDefaultString);
511 [message setDefaultBytes:defaultValue.valueData];
512 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
513 XCTAssertTrue(message.hasDefaultBytes);
514 [message setDefaultBytes:nil];
515 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
516 XCTAssertFalse(message.hasDefaultBytes);
517 message.hasDefaultBytes = NO;
518 XCTAssertFalse(message.hasDefaultBytes);
519 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
522 XCTAssertFalse(message.hasOptionalString);
523 XCTAssertEqualObjects(message.optionalString, @"");
524 XCTAssertFalse(message.hasOptionalString);
525 message.optionalString = nil;
526 XCTAssertFalse(message.hasOptionalString);
527 XCTAssertEqualObjects(message.optionalString, @"");
529 message.optionalString = string;
530 XCTAssertEqualObjects(message.optionalString, string);
531 XCTAssertTrue(message.hasOptionalString);
532 message.optionalString = nil;
533 XCTAssertFalse(message.hasOptionalString);
534 XCTAssertEqualObjects(message.optionalString, @"");
537 XCTAssertFalse(message.hasOptionalBytes);
538 XCTAssertEqualObjects(message.optionalBytes, GPBEmptyNSData());
539 XCTAssertFalse(message.hasOptionalBytes);
540 message.optionalBytes = nil;
541 XCTAssertFalse(message.hasOptionalBytes);
542 XCTAssertEqualObjects(message.optionalBytes, GPBEmptyNSData());
544 message.optionalBytes = data;
545 XCTAssertEqualObjects(message.optionalBytes, data);
546 XCTAssertTrue(message.hasOptionalBytes);
547 message.optionalBytes = nil;
548 XCTAssertFalse(message.hasOptionalBytes);
549 XCTAssertEqualObjects(message.optionalBytes, GPBEmptyNSData());
551 // Test lazy message setting
552 XCTAssertFalse(message.hasOptionalLazyMessage);
553 XCTAssertNotNil(message.optionalLazyMessage);
554 XCTAssertFalse(message.hasOptionalLazyMessage);
555 message.hasOptionalLazyMessage = NO;
556 XCTAssertFalse(message.hasOptionalLazyMessage);
557 XCTAssertNotNil(message.optionalLazyMessage);
558 XCTAssertFalse(message.hasOptionalLazyMessage);
559 message.optionalLazyMessage = nil;
560 XCTAssertFalse(message.hasOptionalLazyMessage);
563 XCTAssertFalse(message.hasOptionalLazyMessage);
564 message.optionalLazyMessage.bb = 1;
565 XCTAssertTrue(message.hasOptionalLazyMessage);
566 XCTAssertEqual(message.optionalLazyMessage.bb, 1);
567 XCTAssertNotNil(message.optionalLazyMessage);
568 message.optionalLazyMessage = nil;
569 XCTAssertFalse(message.hasOptionalLazyMessage);
570 XCTAssertEqual(message.optionalLazyMessage.bb, 0);
571 XCTAssertFalse(message.hasOptionalLazyMessage);
572 XCTAssertNotNil(message.optionalLazyMessage);
579 TestAllTypes *message = [TestAllTypes message];
580 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
581 [self modifyRepeatedFields:message];
582 [self assertRepeatedFieldsModified:message
587 TestAllTypes *message = [TestAllTypes message];
588 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
589 [self clearAllFields:message];
590 [self assertClear:message];
591 TestAllTypes *message2 = [TestAllTypes message];
592 XCTAssertEqualObjects(message, message2);
596 TestAllTypes *message = [TestAllTypes message];
597 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
598 [self clearAllFields:message];
599 [self assertClear:message];
600 [self assertClearKVC:message];
605 GPBMessage *message1 = [TestAllExtensions message];
612 GPBMessage *message2 = [TestAllExtensions message];
623 // Clearing an unset extension field shouldn't make the target message
625 GPBMessage *message3 = [TestAllExtensions message];
634 TestAllTypes *message = [TestAllTypes message];
638 XCTAssertFalse(message.hasOptionalGroup);
639 XCTAssertFalse(message.hasOptionalNestedMessage);
640 XCTAssertFalse(message.hasOptionalForeignMessage);
641 XCTAssertFalse(message.hasOptionalImportMessage);
642 XCTAssertFalse(message.hasOptionalPublicImportMessage);
643 XCTAssertFalse(message.hasOptionalLazyMessage);
647 TestAllTypes_OptionalGroup *optionalGroup = [message.optionalGroup retain];
649 [message.optionalNestedMessage retain];
651 [message.optionalForeignMessage retain];
652 ImportMessage *optionalImportMessage = [message.optionalImportMessage retain];
654 [message.optionalPublicImportMessage retain];
656 [message.optionalLazyMessage retain];
668 XCTAssertFalse(message.hasOptionalGroup);
669 XCTAssertFalse(message.hasOptionalNestedMessage);
670 XCTAssertFalse(message.hasOptionalForeignMessage);
671 XCTAssertFalse(message.hasOptionalImportMessage);
672 XCTAssertFalse(message.hasOptionalPublicImportMessage);
673 XCTAssertFalse(message.hasOptionalLazyMessage);
675 // And they set that value back in to the message since the value created was
678 XCTAssertEqual(message.optionalGroup, optionalGroup);
679 XCTAssertEqual(message.optionalNestedMessage, optionalNestedMessage);
680 XCTAssertEqual(message.optionalForeignMessage, optionalForeignMessage);
681 XCTAssertEqual(message.optionalImportMessage, optionalImportMessage);
682 XCTAssertEqual(message.optionalPublicImportMessage,
684 XCTAssertEqual(message.optionalLazyMessage, optionalLazyMessage);
686 // And the default objects for a second message should be distinct (again,
689 TestAllTypes *message2 = [TestAllTypes message];
703 message.optionalGroup = nil;
704 message.optionalNestedMessage = nil;
705 message.optionalForeignMessage = nil;
706 message.optionalImportMessage = nil;
707 message.optionalPublicImportMessage = nil;
708 message.optionalLazyMessage = nil;
710 XCTAssertFalse(message.hasOptionalGroup);
711 XCTAssertFalse(message.hasOptionalNestedMessage);
712 XCTAssertFalse(message.hasOptionalForeignMessage);
713 XCTAssertFalse(message.hasOptionalImportMessage);
714 XCTAssertFalse(message.hasOptionalPublicImportMessage);
715 XCTAssertFalse(message.hasOptionalLazyMessage);
718 XCTAssertNotEqual(message.optionalGroup, optionalGroup);
719 XCTAssertNotEqual(message.optionalNestedMessage, optionalNestedMessage);
720 XCTAssertNotEqual(message.optionalForeignMessage, optionalForeignMessage);
721 XCTAssertNotEqual(message.optionalImportMessage, optionalImportMessage);
722 XCTAssertNotEqual(message.optionalPublicImportMessage,
724 XCTAssertNotEqual(message.optionalLazyMessage, optionalLazyMessage);
735 // Multiple objects pointing to the same autocreated message.
736 TestAllTypes *message = [TestAllTypes message];
737 TestAllTypes *message2 = [TestAllTypes message];
738 message2.optionalGroup = message.optionalGroup;
740 XCTAssertFalse([message hasOptionalGroup]);
742 XCTAssertTrue([message hasOptionalGroup]);
748 TestAllTypes *message = [TestAllTypes message];
749 message.optionalGroup.a = 42;
750 XCTAssertNotNil(message.optionalNestedMessage);
751 TestAllTypes *message2 = [[message copy] autorelease];
756 XCTAssertNotEqual(message.optionalNestedMessage,
763 TestRecursiveMessage *message = [TestRecursiveMessage message];
764 TestRecursiveMessage *message_inner = [message.a.a.a retain];
766 XCTAssertTrue(GPBWasMessageAutocreatedBy(message_inner, message.a.a));
767 [message.a.a clear];
768 XCTAssertFalse(GPBWasMessageAutocreatedBy(message_inner, message.a.a));
771 XCTAssertNotEqual(message.a.a.a, message_inner);
778 TestAllTypes *message = [TestAllTypes message];
782 TestAllTypes *message2 = [TestAllTypes message];
784 message.optionalForeignMessage = subMessage;
785 XCTAssertTrue(GPBWasMessageAutocreatedBy(message.optionalForeignMessage,
790 XCTAssertEqual(message.optionalForeignMessage, subMessage);
795 TestRecursiveMessage *message = [TestRecursiveMessage message];
796 TestRecursiveMessage *message_inner = [message.a.a retain];
797 XCTAssertFalse([message hasA]);
798 XCTAssertFalse([message.a hasA]);
799 message.a.a = nil;
801 // |message.a| has to be made visible, but |message.a.a| was set to nil so
803 XCTAssertTrue([message hasA]);
804 XCTAssertFalse([message.a hasA]);
807 XCTAssertFalse(GPBWasMessageAutocreatedBy(message_inner, message.a));
810 // message.
812 XCTAssertNotEqual(message.a.a, message_inner);
820 TestAllTypes *message = [TestAllTypes message];
821 TestAllTypes_NestedMessage *nestedMessage = message.optionalNestedMessage;
822 XCTAssertFalse([message hasOptionalNestedMessage]);
823 [message setHasOptionalNestedMessage:NO];
824 XCTAssertFalse([message hasOptionalNestedMessage]);
825 XCTAssertEqual(message.optionalNestedMessage, nestedMessage);
831 TestRecursiveMessage *message = [TestRecursiveMessage message];
832 message.a.a.a.a.i = 42;
833 XCTAssertTrue([message hasA]);
834 XCTAssertTrue([message.a hasA]);
835 XCTAssertTrue([message.a.a hasA]);
836 XCTAssertTrue([message.a.a.a hasA]);
837 XCTAssertFalse([message.a.a.a.a hasA]);
838 XCTAssertEqual(message.a.a.a.a.i, 42);
844 TestRecursiveMessage *message = [TestRecursiveMessage message];
845 message.a.a.a.a.hasI = NO;
846 XCTAssertFalse([message hasA]);
847 XCTAssertFalse([message.a hasA]);
848 XCTAssertFalse([message.a.a hasA]);
849 XCTAssertFalse([message.a.a.a hasA]);
853 TestRecursiveMessage *message = [TestRecursiveMessage message];
854 TestRecursiveMessage *messageLevel1 = [message.a retain];
855 TestRecursiveMessage *messageLevel2 = [message.a.a retain];
856 TestRecursiveMessage *messageLevel3 = [message.a.a.a retain];
857 TestRecursiveMessage *messageLevel4 = [message.a.a.a.a retain];
858 XCTAssertTrue(GPBWasMessageAutocreatedBy(messageLevel1, message));
864 message.a = message.a.a;
865 XCTAssertEqual(message.a, messageLevel2);
866 XCTAssertTrue([message hasA]);
867 XCTAssertEqual(message.a.a, messageLevel3);
868 XCTAssertFalse([message.a hasA]);
869 XCTAssertEqual(message.a.a.a, messageLevel4);
871 message)); // Because it was orphaned.
882 TestRecursiveMessage *message = [TestRecursiveMessage message];
883 TestRecursiveMessage *messageLevel1 = [message.a retain];
884 TestRecursiveMessage *messageLevel2 = [message.a.a retain];
885 TestRecursiveMessage *messageLevel3 = [message.a.a.a retain];
886 TestRecursiveMessage *messageLevel4 = [message.a.a.a.a retain];
887 XCTAssertTrue(GPBWasMessageAutocreatedBy(messageLevel1, message));
894 message.a.a = message.a;
895 XCTAssertTrue([message hasA]);
896 XCTAssertEqual(message.a, messageLevel1);
897 XCTAssertTrue([message.a hasA]);
898 XCTAssertEqual(message.a.a, messageLevel1);
899 XCTAssertTrue([message.a.a hasA]);
900 XCTAssertEqual(message.a.a.a, messageLevel1);
902 message)); // Because it was assigned.
908 message.a.a = nil;
909 XCTAssertTrue([message hasA]);
910 XCTAssertFalse([message.a hasA]);
921 TestAllTypes *message = [TestAllTypes message];
923 [message.optionalNestedMessage retain];
925 message.optionalNestedMessage = [TestAllTypes_NestedMessage message];
926 XCTAssertTrue([message hasOptionalNestedMessage]);
927 XCTAssertTrue(message.optionalNestedMessage != nestedMessage);
928 XCTAssertFalse(GPBWasMessageAutocreatedBy(nestedMessage, message));
936 TestAllTypes *message = [TestAllTypes message];
937 XCTAssertNotNil(message.optionalNestedMessage);
938 XCTAssertFalse([message hasOptionalNestedMessage]);
939 XCTAssertNil(message.optionalNestedMessage.unknownFields);
940 XCTAssertFalse([message hasOptionalNestedMessage]);
944 message.optionalNestedMessage.unknownFields = unknownFields;
945 XCTAssertTrue([message hasOptionalNestedMessage]);
947 message.optionalNestedMessage = nil;
948 XCTAssertFalse([message hasOptionalNestedMessage]);
949 [message.optionalNestedMessage setUnknownFields:unknownFields];
950 XCTAssertTrue([message hasOptionalNestedMessage]);
955 TestAllTypes *message = [TestAllTypes message];
956 XCTAssertNotNil(message.optionalNestedMessage);
957 XCTAssertFalse([message hasOptionalNestedMessage]);
958 message.optionalNestedMessage = message.optionalNestedMessage;
959 XCTAssertTrue([message hasOptionalNestedMessage]);
964 TestRecursiveMessage *message;
970 message = [[TestRecursiveMessage alloc] init];
971 messageLevel1 = [message.a retain];
972 messageLevel2 = [message.a.a retain];
973 messageLevel3 = [message.a.a.a retain];
974 messageLevel4 = [message.a.a.a.a retain];
975 message.a.i = 1;
978 XCTAssertEqual(message.retainCount, (NSUInteger)1);
979 [message release];
991 // Basic tests for default creation of arrays in a message.
992 TestRecursiveMessageWithRepeatedField *message =
993 [TestRecursiveMessageWithRepeatedField message];
995 [TestRecursiveMessageWithRepeatedField message];
998 XCTAssertNotNil(message.a.a.iArray);
999 XCTAssertFalse([message hasA]);
1000 XCTAssertFalse([message.a hasA]);
1006 [message.a.a.iArray addValue:42];
1007 XCTAssertTrue([message hasA]);
1008 XCTAssertTrue([message.a hasA]);
1009 XCTAssertEqual([message.a.a.iArray count], (NSUInteger)1);
1019 [TestRecursiveMessageWithRepeatedField message];
1021 [TestRecursiveMessageWithRepeatedField message];
1031 [TestRecursiveMessageWithRepeatedField message];
1033 [TestRecursiveMessageWithRepeatedField message];
1045 TestAllTypes *message = [TestAllTypes message];
1046 XCTAssertNotNil(message.repeatedStringArray);
1047 XCTAssertNotNil(message.repeatedInt32Array);
1048 TestAllTypes *message2 = [[message copy] autorelease];
1050 XCTAssertNotEqual(message.repeatedStringArray, message2.repeatedStringArray);
1051 XCTAssertNotEqual(message.repeatedInt32Array, message2.repeatedInt32Array);
1055 TestAllTypes *message3 = [TestAllTypes message];
1058 XCTAssertNotNil(message.repeatedInt32Array);
1059 XCTAssertNotNil(message.repeatedStringArray);
1071 TestAllTypes *message = [TestAllTypes message];
1074 TestAllTypes *message2 = [TestAllTypes message];
1075 message.repeatedInt32Array = message2.repeatedInt32Array;
1076 message.repeatedStringArray = message2.repeatedStringArray;
1078 XCTAssertEqual(message.repeatedInt32Array->_autocreator, message2);
1079 XCTAssertTrue([message.repeatedStringArray
1082 ((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator,
1086 XCTAssertNil(message.repeatedInt32Array->_autocreator);
1088 [message.repeatedStringArray isKindOfClass:[GPBAutocreatedArray class]]);
1090 ((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator);
1095 TestAllTypes *message = [TestAllTypes message];
1096 GPBInt32Array *repeatedInt32Array = [message.repeatedInt32Array retain];
1098 (GPBAutocreatedArray *)[message.repeatedStringArray retain];
1100 XCTAssertEqual(repeatedInt32Array->_autocreator, message);
1101 XCTAssertEqual(repeatedStringArray->_autocreator, message);
1102 message.repeatedInt32Array = nil;
1103 message.repeatedStringArray = nil;
1115 TestAllTypes *message = [TestAllTypes message];
1116 [message.repeatedStringArray addObject:@"foo"];
1117 XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
1118 message.repeatedStringArray = [NSMutableArray arrayWithObjects:@"bar", @"bar2", nil];
1119 XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)2);
1120 message.repeatedStringArray = [NSMutableArray arrayWithObject:@"baz"];
1121 XCTAssertEqual(message.repeatedStringArray_Count, (NSUInteger)1);
1128 TestRecursiveMessageWithRepeatedField *message =
1129 [TestRecursiveMessageWithRepeatedField message];
1130 XCTAssertNotNil(message.a);
1131 XCTAssertNotNil(message.a.iArray);
1132 XCTAssertFalse([message hasA]);
1133 GPBInt32Array *iArray = [message.a.iArray retain];
1134 XCTAssertEqual(iArray->_autocreator, message.a); // Pointer comparison
1135 message.a.iArray = [GPBInt32Array arrayWithValue:1];
1136 XCTAssertTrue([message hasA]);
1137 XCTAssertNotEqual(message.a.iArray, iArray); // Pointer comparison
1143 TestRecursiveMessageWithRepeatedField *message =
1144 [TestRecursiveMessageWithRepeatedField message];
1145 XCTAssertNotNil(message.a);
1146 XCTAssertNotNil(message.a.strArray);
1147 XCTAssertFalse([message hasA]);
1149 (GPBAutocreatedArray *)[message.a.strArray retain];
1151 XCTAssertEqual(strArray->_autocreator, message.a); // Pointer comparison
1152 message.a.strArray = [NSMutableArray arrayWithObject:@"foo"];
1153 XCTAssertTrue([message hasA]);
1154 XCTAssertNotEqual(message.a.strArray, strArray); // Pointer comparison
1163 TestRecursiveMessageWithRepeatedField *message =
1164 [TestRecursiveMessageWithRepeatedField message];
1165 XCTAssertNotNil(message.a);
1166 XCTAssertNotNil(message.a.iArray);
1167 XCTAssertFalse([message hasA]);
1168 message.a.iArray = message.a.iArray;
1169 XCTAssertTrue([message hasA]);
1170 XCTAssertNil(message.a.iArray->_autocreator);
1174 TestRecursiveMessageWithRepeatedField *message =
1175 [TestRecursiveMessageWithRepeatedField message];
1176 XCTAssertNotNil(message.a);
1177 XCTAssertNotNil(message.a.strArray);
1178 XCTAssertFalse([message hasA]);
1179 message.a.strArray = message.a.strArray;
1180 XCTAssertTrue([message hasA]);
1181 XCTAssertTrue([message.a.strArray isKindOfClass:[GPBAutocreatedArray class]]);
1182 XCTAssertNil(((GPBAutocreatedArray *)message.a.strArray)->_autocreator);
1189 TestRecursiveMessageWithRepeatedField *message =
1190 [TestRecursiveMessageWithRepeatedField message];
1191 [message.a.iArray removeAll];
1192 XCTAssertFalse([message hasA]);
1193 [message.a.strArray removeAllObjects];
1194 XCTAssertFalse([message hasA]);
1198 // Basic tests for default creation of maps in a message.
1199 TestRecursiveMessageWithRepeatedField *message =
1200 [TestRecursiveMessageWithRepeatedField message];
1202 [TestRecursiveMessageWithRepeatedField message];
1205 XCTAssertNotNil(message.a.a.iToI);
1206 XCTAssertFalse([message hasA]);
1207 XCTAssertFalse([message.a hasA]);
1213 [message.a.a.iToI setInt32:100 forKey:200];
1214 XCTAssertTrue([message hasA]);
1215 XCTAssertTrue([message.a hasA]);
1216 XCTAssertEqual([message.a.a.iToI count], (NSUInteger)1);
1226 [TestRecursiveMessageWithRepeatedField message];
1228 [TestRecursiveMessageWithRepeatedField message];
1238 [TestRecursiveMessageWithRepeatedField message];
1240 [TestRecursiveMessageWithRepeatedField message];
1252 TestRecursiveMessageWithRepeatedField *message =
1253 [TestRecursiveMessageWithRepeatedField message];
1254 XCTAssertNotNil(message.strToStr);
1255 XCTAssertNotNil(message.iToI);
1257 [[message copy] autorelease];
1259 XCTAssertNotEqual(message.strToStr, message2.strToStr);
1260 XCTAssertNotEqual(message.iToI, message2.iToI);
1265 [TestRecursiveMessageWithRepeatedField message];
1270 XCTAssertNotNil(message.iToI);
1271 XCTAssertNotNil(message.iToI);
1282 TestRecursiveMessageWithRepeatedField *message =
1283 [TestRecursiveMessageWithRepeatedField message];
1287 [TestRecursiveMessageWithRepeatedField message];
1288 message.iToI = message2.iToI;
1289 message.strToStr = message2.strToStr;
1291 XCTAssertEqual(message.iToI->_autocreator, message2);
1292 XCTAssertTrue([message.strToStr
1295 ((GPBAutocreatedDictionary *)message.strToStr)->_autocreator,
1299 XCTAssertNil(message.iToI->_autocreator);
1301 [message.strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
1303 ((GPBAutocreatedDictionary *)message.strToStr)->_autocreator);
1308 TestRecursiveMessageWithRepeatedField *message =
1309 [TestRecursiveMessageWithRepeatedField message];
1310 GPBInt32Int32Dictionary *iToI = [message.iToI retain];
1312 (GPBAutocreatedDictionary *)[message.strToStr retain];
1314 XCTAssertEqual(iToI->_autocreator, message);
1315 XCTAssertEqual(strToStr->_autocreator, message);
1316 message.iToI = nil;
1317 message.strToStr = nil;
1329 TestRecursiveMessageWithRepeatedField *message =
1330 [TestRecursiveMessageWithRepeatedField message];
1331 message.strToStr[@"foo"] = @"bar";
1332 XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
1333 message.strToStr =
1335 XCTAssertEqual(message.strToStr_Count, (NSUInteger)2);
1336 message.strToStr =
1338 XCTAssertEqual(message.strToStr_Count, (NSUInteger)1);
1345 TestRecursiveMessageWithRepeatedField *message =
1346 [TestRecursiveMessageWithRepeatedField message];
1347 XCTAssertNotNil(message.a);
1348 XCTAssertNotNil(message.a.iToI);
1349 XCTAssertFalse([message hasA]);
1350 GPBInt32Int32Dictionary *iToI = [message.a.iToI retain];
1351 XCTAssertEqual(iToI->_autocreator, message.a); // Pointer comparison
1352 message.a.iToI = [[[GPBInt32Int32Dictionary alloc] init] autorelease];
1353 [message.a.iToI setInt32:6 forKey:7];
1354 XCTAssertTrue([message hasA]);
1355 XCTAssertNotEqual(message.a.iToI, iToI); // Pointer comparison
1361 TestRecursiveMessageWithRepeatedField *message =
1362 [TestRecursiveMessageWithRepeatedField message];
1363 XCTAssertNotNil(message.a);
1364 XCTAssertNotNil(message.a.strToStr);
1365 XCTAssertFalse([message hasA]);
1367 (GPBAutocreatedDictionary *)[message.a.strToStr retain];
1369 XCTAssertEqual(strToStr->_autocreator, message.a); // Pointer comparison
1370 message.a.strToStr =
1372 XCTAssertTrue([message hasA]);
1373 XCTAssertNotEqual(message.a.strToStr, strToStr); // Pointer comparison
1382 TestRecursiveMessageWithRepeatedField *message =
1383 [TestRecursiveMessageWithRepeatedField message];
1384 XCTAssertNotNil(message.a);
1385 XCTAssertNotNil(message.a.iToI);
1386 XCTAssertFalse([message hasA]);
1387 message.a.iToI = message.a.iToI;
1388 XCTAssertTrue([message hasA]);
1389 XCTAssertNil(message.a.iToI->_autocreator);
1393 TestRecursiveMessageWithRepeatedField *message =
1394 [TestRecursiveMessageWithRepeatedField message];
1395 XCTAssertNotNil(message.a);
1396 XCTAssertNotNil(message.a.strToStr);
1397 XCTAssertFalse([message hasA]);
1398 message.a.strToStr = message.a.strToStr;
1399 XCTAssertTrue([message hasA]);
1400 XCTAssertTrue([message.a.strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
1401 XCTAssertNil(((GPBAutocreatedDictionary *)message.a.strToStr)->_autocreator);
1407 TestRecursiveMessageWithRepeatedField *message =
1408 [TestRecursiveMessageWithRepeatedField message];
1409 [message.a.iToI removeAll];
1410 XCTAssertFalse([message hasA]);
1411 [message.a.strToStr removeAllObjects];
1412 XCTAssertFalse([message hasA]);
1416 TestAllExtensions *message = [TestAllExtensions message];
1417 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1418 [self assertAllExtensionsSet:message repeatedCount:kGPBDefaultRepeatCount];
1422 TestAllExtensions *message = [TestAllExtensions message];
1423 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1424 [self modifyRepeatedExtensions:message];
1425 [self assertRepeatedExtensionsModified:message
1430 [self assertExtensionsClear:[TestAllExtensions message]];
1434 TestAllExtensions *message = [TestAllExtensions message];
1435 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1436 [self modifyRepeatedExtensions:message];
1437 TestAllExtensions *message2 = [TestAllExtensions message];
1439 XCTAssertFalse([message isEqual:message2]);
1440 message2 = [TestAllExtensions message];
1443 XCTAssertEqualObjects(message, message2);
1447 TestAllExtensions *message = [TestAllExtensions message];
1448 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1449 [self modifyRepeatedExtensions:message];
1451 message = [TestAllExtensions message];
1452 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1453 TestAllExtensions *message2 = [TestAllExtensions message];
1455 [message2 mergeFrom:message];
1457 XCTAssertEqualObjects(message, message2);
1461 TestAllExtensions *message = [TestAllExtensions message];
1465 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1466 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1468 [message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
1470 [message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
1472 [message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
1473 XCTAssertFalse([message
1476 [message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
1481 [message getExtension:[UnittestRoot optionalGroupExtension]];
1483 [message getExtension:[UnittestRoot optionalNestedMessageExtension]];
1485 [message getExtension:[UnittestRoot optionalForeignMessageExtension]];
1487 [message getExtension:[UnittestRoot optionalImportMessageExtension]];
1488 PublicImportMessage *optionalPublicImportMessage = [message
1491 [message getExtension:[UnittestRoot optionalLazyMessageExtension]];
1503 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1504 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1505 XCTAssertFalse([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
1506 XCTAssertFalse([message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
1507 XCTAssertFalse([message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
1508 XCTAssertFalse([message hasExtension:[UnittestRoot optionalPublicImportMessageExtension]]);
1509 XCTAssertFalse([message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
1511 // And they set that value back in to the message since the value created was
1514 XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]],
1517 [message getExtension:[UnittestRoot optionalNestedMessageExtension]],
1520 [message getExtension:[UnittestRoot optionalForeignMessageExtension]],
1523 [message getExtension:[UnittestRoot optionalImportMessageExtension]],
1526 [message getExtension:[UnittestRoot optionalPublicImportMessageExtension]],
1529 [message getExtension:[UnittestRoot optionalLazyMessageExtension]],
1532 // And the default objects for a second message should be distinct (again,
1535 TestAllExtensions *message2 = [TestAllExtensions message];
1559 [message setExtension:[UnittestRoot optionalGroupExtension] value:nil];
1560 [message setExtension:[UnittestRoot optionalGroupExtension] value:nil];
1561 [message setExtension:[UnittestRoot optionalNestedMessageExtension]
1563 [message setExtension:[UnittestRoot optionalForeignMessageExtension]
1565 [message setExtension:[UnittestRoot optionalImportMessageExtension]
1567 [message setExtension:[UnittestRoot optionalPublicImportMessageExtension]
1569 [message setExtension:[UnittestRoot optionalLazyMessageExtension] value:nil];
1571 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1572 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1574 [message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
1576 [message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
1578 [message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
1579 XCTAssertFalse([message
1582 [message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
1584 XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]],
1587 [message getExtension:[UnittestRoot optionalNestedMessageExtension]],
1590 [message getExtension:[UnittestRoot optionalForeignMessageExtension]],
1593 [message getExtension:[UnittestRoot optionalImportMessageExtension]],
1596 [message
1600 [message getExtension:[UnittestRoot optionalLazyMessageExtension]],
1607 TestAllExtensions *message = [TestAllExtensions message];
1608 TestAllExtensions *message2 = [TestAllExtensions message];
1610 [message setExtension:extension value:[message2 getExtension:extension]];
1611 XCTAssertEqual([message getExtension:extension],
1614 XCTAssertTrue([message hasExtension:extension]);
1620 XCTAssertTrue([message hasExtension:extension]);
1625 TestAllExtensions *message = [TestAllExtensions message];
1631 [message getExtension:optionalGroupExtension];
1634 XCTAssertNotNil([message getExtension:optionalNestedMessageExtesion]);
1635 XCTAssertTrue([message hasExtension:optionalGroupExtension]);
1636 XCTAssertFalse([message hasExtension:optionalNestedMessageExtesion]);
1638 TestAllExtensions *message2 = [[message copy] autorelease];
1642 XCTAssertEqualObjects([message getExtension:optionalGroupExtension],
1645 XCTAssertNotEqual([message getExtension:optionalGroupExtension],
1651 XCTAssertNotEqual([message getExtension:optionalNestedMessageExtesion],
1657 TestAllExtensions *message = [TestAllExtensions message];
1661 [[message getExtension:optionalGroupExtension] retain];
1662 [message clear];
1664 [message getExtension:optionalGroupExtension];
1674 TestAllExtensions *message = [TestAllExtensions message];
1679 TestAllExtensions *message2 = [TestAllExtensions message];
1680 [message setExtension:optionalGroupExtension
1683 [message getExtension:optionalGroupExtension], message2));
1687 [message getExtension:optionalGroupExtension], message));
1692 TestAllExtensions *message = [TestAllExtensions message];
1696 [[message getExtension:optionalGroupExtension] retain];
1697 [message clearExtension:optionalGroupExtension];
1699 [message getExtension:optionalGroupExtension];
1701 XCTAssertFalse([message hasExtension:optionalGroupExtension]);
1708 TestAllExtensions *message_lvl2 = [message getExtension:recursiveExtension];
1712 XCTAssertFalse([message hasExtension:recursiveExtension]);
1718 TestAllExtensions *message = [TestAllExtensions message];
1721 TestAllExtensions *message_lvl2 = [message getExtension:recursiveExtension];
1726 XCTAssertFalse([message hasExtension:recursiveExtension]);
1731 XCTAssertTrue([message hasExtension:recursiveExtension]);
1737 XCTAssertFalse(GPBWasMessageAutocreatedBy(message_lvl2, message));
1742 TestAllExtensions *message = [TestAllExtensions message];
1745 XCTAssertNotNil([message getExtension:optionalGroupExtension]);
1746 XCTAssertFalse([message hasExtension:optionalGroupExtension]);
1747 [message setExtension:optionalGroupExtension
1748 value:[message getExtension:optionalGroupExtension]];
1749 XCTAssertTrue([message hasExtension:optionalGroupExtension]);
1757 TestAllExtensions *message;
1762 message = [[TestAllExtensions alloc] init];
1763 message_lvl2 = [[message getExtension:recursiveExtension] retain];
1770 XCTAssertEqual(message.retainCount, (NSUInteger)1);
1772 [message release];
1790 TestAllExtensions *message;
1792 message = [[TestAllExtensions alloc] init];
1793 [message getExtension:recursiveExtension];
1798 [message setExtension:recursiveExtension
1799 value:[message getExtension:recursiveExtension]];
1800 XCTAssertTrue([message hasExtension:recursiveExtension]);
1801 [message release];
1805 TestRecursiveMessage *message = [TestRecursiveMessage message];
1806 XCTAssertNotNil(message.a);
1807 XCTAssertNotNil(message.a.a);
1808 XCTAssertEqual(message.a.a.i, 0);
1815 GPBMessage *message = [GPBMessage message];
1816 [message setUnknownFields:unknowns];
1817 NSData *data = [message data];
1820 XCTAssertEqualObjects(message, message2);
1827 GPBMessage *message1 = [GPBMessage message];
1834 GPBMessage *message2 = [GPBMessage message];
1857 ObjcWeirdDefaults *message = [ObjcWeirdDefaults message];
1858 GPBDescriptor *descriptor = [[message class] descriptor];
1862 XCTAssertFalse(message.hasFoo);
1863 XCTAssertEqualObjects(message.foo, @"");
1868 XCTAssertFalse(message.hasBar);
1869 XCTAssertEqualObjects(message.bar, GPBEmptyNSData());
1887 ObjCPropertyNaming *msg = [ObjCPropertyNaming message];
1950 EnumTestMsg *msg = [EnumTestMsg message];
2015 self_Class *msg = [self_Class message];
2056 MessageWithOneBasedEnum *enumMsg = [MessageWithOneBasedEnum message];
2064 BoolOnlyMessage *msg1 = [BoolOnlyMessage message];
2065 BoolOnlyMessage *msg2 = [BoolOnlyMessage message];
2126 TestMessageOfMaps *msg = [TestMessageOfMaps message];
2141 TestAllTypes *subMsg1 = [TestAllTypes message];
2143 TestAllTypes *subMsg2 = [TestAllTypes message];
2145 TestAllTypes *subMsg3 = [TestAllTypes message];