Lines Matching refs:message
54 TestAllTypes *message = [TestAllTypes message];
55 [message setOptionalInt32:1];
56 [message setOptionalString:@"foo"];
57 [message setOptionalForeignMessage:[ForeignMessage message]];
58 [message.repeatedStringArray addObject:@"bar"];
59 return message;
63 TestAllTypes *message = [TestAllTypes message];
64 [message setOptionalInt64:2];
65 [message setOptionalString:@"baz"];
66 ForeignMessage *foreignMessage = [ForeignMessage message];
68 [message setOptionalForeignMessage:foreignMessage];
69 [message.repeatedStringArray addObject:@"qux"];
70 return message;
74 TestAllTypes *message = [TestAllTypes message];
75 [message setOptionalInt64:2];
76 [message setOptionalString:@"baz"];
77 [message.repeatedStringArray addObject:@"qux"];
78 return message;
82 TestAllTypes *message = [TestAllTypes message];
83 [message setOptionalInt32:1];
84 [message setOptionalInt64:2];
85 [message setOptionalString:@"foo"];
86 ForeignMessage *foreignMessage = [ForeignMessage message];
88 [message setOptionalForeignMessage:foreignMessage];
89 [message.repeatedStringArray addObject:@"qux"];
90 [message.repeatedStringArray addObject:@"bar"];
91 return message;
95 TestAllTypes *message = [TestAllTypes message];
96 [message setOptionalInt32:1];
97 [message setOptionalInt64:2];
98 [message setOptionalString:@"foo"];
99 ForeignMessage *foreignMessage = [ForeignMessage message];
100 [message setOptionalForeignMessage:foreignMessage];
101 [message.repeatedStringArray addObject:@"qux"];
102 [message.repeatedStringArray addObject:@"bar"];
103 return message;
107 TestAllExtensions *message = [TestAllExtensions message];
108 [message setExtension:[UnittestRoot optionalInt32Extension] value:@5];
109 [message setExtension:[UnittestRoot optionalStringExtension] value:@"foo"];
110 ForeignMessage *foreignMessage = [ForeignMessage message];
112 [message setExtension:[UnittestRoot optionalForeignMessageExtension]
115 [TestAllTypes_NestedMessage message];
116 [message setExtension:[UnittestRoot optionalNestedMessageExtension]
118 return message;
122 TestAllExtensions *message = [TestAllExtensions message];
123 [message setExtension:[UnittestRoot optionalInt64Extension] value:@6];
124 [message setExtension:[UnittestRoot optionalStringExtension] value:@"bar"];
125 ForeignMessage *foreignMessage = [ForeignMessage message];
126 [message setExtension:[UnittestRoot optionalForeignMessageExtension]
129 [TestAllTypes_NestedMessage message];
131 [message setExtension:[UnittestRoot optionalNestedMessageExtension]
133 return message;
137 TestAllExtensions *message = [TestAllExtensions message];
138 [message setExtension:[UnittestRoot optionalInt32Extension] value:@5];
139 [message setExtension:[UnittestRoot optionalInt64Extension] value:@6];
140 [message setExtension:[UnittestRoot optionalStringExtension] value:@"bar"];
141 ForeignMessage *foreignMessage = [ForeignMessage message];
143 [message setExtension:[UnittestRoot optionalForeignMessageExtension]
146 [TestAllTypes_NestedMessage message];
148 [message setExtension:[UnittestRoot optionalNestedMessageExtension]
150 return message;
175 result = [TestAllTypes message];
216 TestRequired *message = [TestRequired message];
217 [message setA:1];
218 [message setB:2];
219 [message setC:3];
220 return message;
224 TestRequired *message = [TestRequired message];
226 XCTAssertFalse(message.initialized);
227 [message setA:1];
228 XCTAssertFalse(message.initialized);
229 [message setB:1];
230 XCTAssertFalse(message.initialized);
231 [message setC:1];
232 XCTAssertTrue(message.initialized);
236 TestRequiredForeign *message = [TestRequiredForeign message];
238 XCTAssertTrue(message.initialized);
240 [message setOptionalMessage:[TestRequired message]];
241 XCTAssertFalse(message.initialized);
243 [message setOptionalMessage:self.testRequiredInitialized];
244 XCTAssertTrue(message.initialized);
246 [message.repeatedMessageArray addObject:[TestRequired message]];
247 XCTAssertFalse(message.initialized);
249 [message.repeatedMessageArray removeAllObjects];
250 [message.repeatedMessageArray addObject:self.testRequiredInitialized];
251 XCTAssertTrue(message.initialized);
255 TestAllExtensions *message = [TestAllExtensions message];
257 XCTAssertTrue(message.initialized);
259 [message setExtension:[TestRequired single] value:[TestRequired message]];
260 XCTAssertFalse(message.initialized);
262 [message setExtension:[TestRequired single]
264 XCTAssertTrue(message.initialized);
266 [message addExtension:[TestRequired multi] value:[TestRequired message]];
267 XCTAssertFalse(message.initialized);
269 [message setExtension:[TestRequired multi]
272 XCTAssertTrue(message.initialized);
276 TestRequired *message = [TestRequired message];
277 NSData *data = [message data];
284 XCTAssertFalse(message.initialized);
290 TestRequired *message = [TestRequired message];
291 XCTAssertFalse(message.initialized);
295 TestRequiredForeign *message = [TestRequiredForeign message];
296 [message setOptionalMessage:[TestRequired message]];
297 [message.repeatedMessageArray addObject:[TestRequired message]];
298 [message.repeatedMessageArray addObject:[TestRequired message]];
299 NSData *data = [message data];
306 XCTAssertFalse(message.initialized);
313 TestRequiredForeign *message = [TestRequiredForeign message];
314 [message setOptionalMessage:[TestRequired message]];
315 [message.repeatedMessageArray addObject:[TestRequired message]];
316 [message.repeatedMessageArray addObject:[TestRequired message]];
318 XCTAssertFalse(message.initialized);
352 TestAllTypes *message = [TestAllTypes message];
353 message.hasOptionalNestedMessage = NO;
354 [message setOptionalNestedMessage:[TestAllTypes_NestedMessage message]];
355 message.hasOptionalNestedMessage = NO;
356 [message setOptionalNestedMessage:[TestAllTypes_NestedMessage message]];
357 [message setOptionalNestedMessage:nil];
358 message.hasOptionalNestedMessage = NO;
362 TestAllTypes *message = [TestAllTypes message];
363 XCTAssertThrows([message setHasOptionalNestedMessage:YES]);
385 TestAllTypes *message = [TestAllTypes message];
386 [self assertClear:message];
390 TestAllTypes *message = [TestAllTypes message];
391 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
392 [self assertAllFieldsSet:message repeatedCount:kGPBDefaultRepeatCount];
396 TestAllTypes *message = [TestAllTypes message];
397 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
398 [self assertAllFieldsKVCMatch:message];
402 TestAllTypes *message = [TestAllTypes message];
403 [self setAllFieldsViaKVC:message repeatedCount:kGPBDefaultRepeatCount];
404 [self assertAllFieldsKVCMatch:message];
405 [self assertAllFieldsSet:message repeatedCount:kGPBDefaultRepeatCount];
406 [self assertAllFieldsKVCMatch:message];
411 TestAllTypes *message = [TestAllTypes message];
412 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
424 [message setUnknownFields:unknownFields];
426 NSString *description = [message description];
429 GPBMessage *message2 = [TestAllExtensions message];
441 // message correctly.
442 TestAllTypes *message = [TestAllTypes message];
443 GPBDescriptor *descriptor = [[message class] descriptor];
449 [message setDefaultInt32:defaultValue.valueInt32];
450 XCTAssertTrue(message.hasDefaultInt32);
451 XCTAssertEqual(message.defaultInt32, defaultValue.valueInt32);
454 message = [TestAllTypes message];
458 [message setDefaultString:defaultValue.valueString];
459 XCTAssertTrue(message.hasDefaultString);
460 XCTAssertEqualObjects(message.defaultString, defaultValue.valueString);
463 message = [TestAllTypes message];
464 XCTAssertEqualObjects(message.defaultString, @"hello");
465 XCTAssertFalse(message.hasDefaultString);
469 [message setDefaultString:defaultValue.valueString];
470 XCTAssertEqualObjects(message.defaultString, @"hello");
471 XCTAssertTrue(message.hasDefaultString);
472 [message setDefaultString:nil];
473 XCTAssertEqualObjects(message.defaultString, @"hello");
474 XCTAssertFalse(message.hasDefaultString);
475 message.hasDefaultString = NO;
476 XCTAssertFalse(message.hasDefaultString);
477 XCTAssertEqualObjects(message.defaultString, @"hello");
481 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
482 XCTAssertFalse(message.hasDefaultString);
486 [message setDefaultBytes:defaultValue.valueData];
487 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
488 XCTAssertTrue(message.hasDefaultBytes);
489 [message setDefaultBytes:nil];
490 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
491 XCTAssertFalse(message.hasDefaultBytes);
492 message.hasDefaultBytes = NO;
493 XCTAssertFalse(message.hasDefaultBytes);
494 XCTAssertEqualObjects(message.defaultBytes, defaultBytes);
497 XCTAssertFalse(message.hasOptionalString);
498 XCTAssertEqualObjects(message.optionalString, @"");
499 XCTAssertFalse(message.hasOptionalString);
500 message.optionalString = nil;
501 XCTAssertFalse(message.hasOptionalString);
502 XCTAssertEqualObjects(message.optionalString, @"");
504 message.optionalString = string;
505 XCTAssertEqualObjects(message.optionalString, string);
506 XCTAssertTrue(message.hasOptionalString);
507 message.optionalString = nil;
508 XCTAssertFalse(message.hasOptionalString);
509 XCTAssertEqualObjects(message.optionalString, @"");
512 XCTAssertFalse(message.hasOptionalBytes);
513 XCTAssertEqualObjects(message.optionalBytes, GPBEmptyNSData());
514 XCTAssertFalse(message.hasOptionalBytes);
515 message.optionalBytes = nil;
516 XCTAssertFalse(message.hasOptionalBytes);
517 XCTAssertEqualObjects(message.optionalBytes, GPBEmptyNSData());
519 message.optionalBytes = data;
520 XCTAssertEqualObjects(message.optionalBytes, data);
521 XCTAssertTrue(message.hasOptionalBytes);
522 message.optionalBytes = nil;
523 XCTAssertFalse(message.hasOptionalBytes);
524 XCTAssertEqualObjects(message.optionalBytes, GPBEmptyNSData());
526 // Test lazy message setting
527 XCTAssertFalse(message.hasOptionalLazyMessage);
528 XCTAssertNotNil(message.optionalLazyMessage);
529 XCTAssertFalse(message.hasOptionalLazyMessage);
530 message.hasOptionalLazyMessage = NO;
531 XCTAssertFalse(message.hasOptionalLazyMessage);
532 XCTAssertNotNil(message.optionalLazyMessage);
533 XCTAssertFalse(message.hasOptionalLazyMessage);
534 message.optionalLazyMessage = nil;
535 XCTAssertFalse(message.hasOptionalLazyMessage);
538 XCTAssertFalse(message.hasOptionalLazyMessage);
539 message.optionalLazyMessage.bb = 1;
540 XCTAssertTrue(message.hasOptionalLazyMessage);
541 XCTAssertEqual(message.optionalLazyMessage.bb, 1);
542 XCTAssertNotNil(message.optionalLazyMessage);
543 message.optionalLazyMessage = nil;
544 XCTAssertFalse(message.hasOptionalLazyMessage);
545 XCTAssertEqual(message.optionalLazyMessage.bb, 0);
546 XCTAssertFalse(message.hasOptionalLazyMessage);
547 XCTAssertNotNil(message.optionalLazyMessage);
554 TestAllTypes *message = [TestAllTypes message];
555 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
556 [self modifyRepeatedFields:message];
557 [self assertRepeatedFieldsModified:message
562 TestAllTypes *message = [TestAllTypes message];
563 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
564 [self clearAllFields:message];
565 [self assertClear:message];
566 TestAllTypes *message2 = [TestAllTypes message];
567 XCTAssertEqualObjects(message, message2);
571 TestAllTypes *message = [TestAllTypes message];
572 [self setAllFields:message repeatedCount:kGPBDefaultRepeatCount];
573 [self clearAllFields:message];
574 [self assertClear:message];
575 [self assertClearKVC:message];
580 GPBMessage *message1 = [TestAllExtensions message];
587 GPBMessage *message2 = [TestAllExtensions message];
598 // Clearing an unset extension field shouldn't make the target message
600 GPBMessage *message3 = [TestAllExtensions message];
609 TestAllTypes *message = [TestAllTypes message];
613 XCTAssertFalse(message.hasOptionalGroup);
614 XCTAssertFalse(message.hasOptionalNestedMessage);
615 XCTAssertFalse(message.hasOptionalForeignMessage);
616 XCTAssertFalse(message.hasOptionalImportMessage);
617 XCTAssertFalse(message.hasOptionalPublicImportMessage);
618 XCTAssertFalse(message.hasOptionalLazyMessage);
622 TestAllTypes_OptionalGroup *optionalGroup = [message.optionalGroup retain];
624 [message.optionalNestedMessage retain];
626 [message.optionalForeignMessage retain];
627 ImportMessage *optionalImportMessage = [message.optionalImportMessage retain];
629 [message.optionalPublicImportMessage retain];
631 [message.optionalLazyMessage retain];
643 XCTAssertFalse(message.hasOptionalGroup);
644 XCTAssertFalse(message.hasOptionalNestedMessage);
645 XCTAssertFalse(message.hasOptionalForeignMessage);
646 XCTAssertFalse(message.hasOptionalImportMessage);
647 XCTAssertFalse(message.hasOptionalPublicImportMessage);
648 XCTAssertFalse(message.hasOptionalLazyMessage);
650 // And they set that value back in to the message since the value created was
653 XCTAssertEqual(message.optionalGroup, optionalGroup);
654 XCTAssertEqual(message.optionalNestedMessage, optionalNestedMessage);
655 XCTAssertEqual(message.optionalForeignMessage, optionalForeignMessage);
656 XCTAssertEqual(message.optionalImportMessage, optionalImportMessage);
657 XCTAssertEqual(message.optionalPublicImportMessage,
659 XCTAssertEqual(message.optionalLazyMessage, optionalLazyMessage);
661 // And the default objects for a second message should be distinct (again,
664 TestAllTypes *message2 = [TestAllTypes message];
678 message.optionalGroup = nil;
679 message.optionalNestedMessage = nil;
680 message.optionalForeignMessage = nil;
681 message.optionalImportMessage = nil;
682 message.optionalPublicImportMessage = nil;
683 message.optionalLazyMessage = nil;
685 XCTAssertFalse(message.hasOptionalGroup);
686 XCTAssertFalse(message.hasOptionalNestedMessage);
687 XCTAssertFalse(message.hasOptionalForeignMessage);
688 XCTAssertFalse(message.hasOptionalImportMessage);
689 XCTAssertFalse(message.hasOptionalPublicImportMessage);
690 XCTAssertFalse(message.hasOptionalLazyMessage);
693 XCTAssertNotEqual(message.optionalGroup, optionalGroup);
694 XCTAssertNotEqual(message.optionalNestedMessage, optionalNestedMessage);
695 XCTAssertNotEqual(message.optionalForeignMessage, optionalForeignMessage);
696 XCTAssertNotEqual(message.optionalImportMessage, optionalImportMessage);
697 XCTAssertNotEqual(message.optionalPublicImportMessage,
699 XCTAssertNotEqual(message.optionalLazyMessage, optionalLazyMessage);
710 // Multiple objects pointing to the same autocreated message.
711 TestAllTypes *message = [TestAllTypes message];
712 TestAllTypes *message2 = [TestAllTypes message];
713 message2.optionalGroup = message.optionalGroup;
715 XCTAssertFalse([message hasOptionalGroup]);
717 XCTAssertTrue([message hasOptionalGroup]);
723 TestAllTypes *message = [TestAllTypes message];
724 message.optionalGroup.a = 42;
725 XCTAssertNotNil(message.optionalNestedMessage);
726 TestAllTypes *message2 = [[message copy] autorelease];
731 XCTAssertNotEqual(message.optionalNestedMessage,
738 TestRecursiveMessage *message = [TestRecursiveMessage message];
739 TestRecursiveMessage *message_inner = [message.a.a.a retain];
741 XCTAssertTrue(GPBWasMessageAutocreatedBy(message_inner, message.a.a));
742 [message.a.a clear];
743 XCTAssertFalse(GPBWasMessageAutocreatedBy(message_inner, message.a.a));
746 XCTAssertNotEqual(message.a.a.a, message_inner);
753 TestAllTypes *message = [TestAllTypes message];
757 TestAllTypes *message2 = [TestAllTypes message];
759 message.optionalForeignMessage = subMessage;
760 XCTAssertTrue(GPBWasMessageAutocreatedBy(message.optionalForeignMessage,
765 XCTAssertEqual(message.optionalForeignMessage, subMessage);
770 TestRecursiveMessage *message = [TestRecursiveMessage message];
771 TestRecursiveMessage *message_inner = [message.a.a retain];
772 XCTAssertFalse([message hasA]);
773 XCTAssertFalse([message.a hasA]);
774 message.a.a = nil;
776 // |message.a| has to be made visible, but |message.a.a| was set to nil so
778 XCTAssertTrue([message hasA]);
779 XCTAssertFalse([message.a hasA]);
782 XCTAssertFalse(GPBWasMessageAutocreatedBy(message_inner, message.a));
785 // message.
787 XCTAssertNotEqual(message.a.a, message_inner);
795 TestAllTypes *message = [TestAllTypes message];
796 TestAllTypes_NestedMessage *nestedMessage = message.optionalNestedMessage;
797 XCTAssertFalse([message hasOptionalNestedMessage]);
798 [message setHasOptionalNestedMessage:NO];
799 XCTAssertFalse([message hasOptionalNestedMessage]);
800 XCTAssertEqual(message.optionalNestedMessage, nestedMessage);
806 TestRecursiveMessage *message = [TestRecursiveMessage message];
807 message.a.a.a.a.i = 42;
808 XCTAssertTrue([message hasA]);
809 XCTAssertTrue([message.a hasA]);
810 XCTAssertTrue([message.a.a hasA]);
811 XCTAssertTrue([message.a.a.a hasA]);
812 XCTAssertFalse([message.a.a.a.a hasA]);
813 XCTAssertEqual(message.a.a.a.a.i, 42);
819 TestRecursiveMessage *message = [TestRecursiveMessage message];
820 message.a.a.a.a.hasI = NO;
821 XCTAssertFalse([message hasA]);
822 XCTAssertFalse([message.a hasA]);
823 XCTAssertFalse([message.a.a hasA]);
824 XCTAssertFalse([message.a.a.a hasA]);
828 TestRecursiveMessage *message = [TestRecursiveMessage message];
829 TestRecursiveMessage *messageLevel1 = [message.a retain];
830 TestRecursiveMessage *messageLevel2 = [message.a.a retain];
831 TestRecursiveMessage *messageLevel3 = [message.a.a.a retain];
832 TestRecursiveMessage *messageLevel4 = [message.a.a.a.a retain];
833 XCTAssertTrue(GPBWasMessageAutocreatedBy(messageLevel1, message));
839 message.a = message.a.a;
840 XCTAssertEqual(message.a, messageLevel2);
841 XCTAssertTrue([message hasA]);
842 XCTAssertEqual(message.a.a, messageLevel3);
843 XCTAssertFalse([message.a hasA]);
844 XCTAssertEqual(message.a.a.a, messageLevel4);
846 message)); // Because it was orphaned.
857 TestRecursiveMessage *message = [TestRecursiveMessage message];
858 TestRecursiveMessage *messageLevel1 = [message.a retain];
859 TestRecursiveMessage *messageLevel2 = [message.a.a retain];
860 TestRecursiveMessage *messageLevel3 = [message.a.a.a retain];
861 TestRecursiveMessage *messageLevel4 = [message.a.a.a.a retain];
862 XCTAssertTrue(GPBWasMessageAutocreatedBy(messageLevel1, message));
869 message.a.a = message.a;
870 XCTAssertTrue([message hasA]);
871 XCTAssertEqual(message.a, messageLevel1);
872 XCTAssertTrue([message.a hasA]);
873 XCTAssertEqual(message.a.a, messageLevel1);
874 XCTAssertTrue([message.a.a hasA]);
875 XCTAssertEqual(message.a.a.a, messageLevel1);
877 message)); // Because it was assigned.
883 message.a.a = nil;
884 XCTAssertTrue([message hasA]);
885 XCTAssertFalse([message.a hasA]);
896 TestAllTypes *message = [TestAllTypes message];
898 [message.optionalNestedMessage retain];
900 message.optionalNestedMessage = [TestAllTypes_NestedMessage message];
901 XCTAssertTrue([message hasOptionalNestedMessage]);
902 XCTAssertTrue(message.optionalNestedMessage != nestedMessage);
903 XCTAssertFalse(GPBWasMessageAutocreatedBy(nestedMessage, message));
911 TestAllTypes *message = [TestAllTypes message];
912 XCTAssertNotNil(message.optionalNestedMessage);
913 XCTAssertFalse([message hasOptionalNestedMessage]);
914 XCTAssertNil(message.optionalNestedMessage.unknownFields);
915 XCTAssertFalse([message hasOptionalNestedMessage]);
919 message.optionalNestedMessage.unknownFields = unknownFields;
920 XCTAssertTrue([message hasOptionalNestedMessage]);
922 message.optionalNestedMessage = nil;
923 XCTAssertFalse([message hasOptionalNestedMessage]);
924 [message.optionalNestedMessage setUnknownFields:unknownFields];
925 XCTAssertTrue([message hasOptionalNestedMessage]);
930 TestAllTypes *message = [TestAllTypes message];
931 XCTAssertNotNil(message.optionalNestedMessage);
932 XCTAssertFalse([message hasOptionalNestedMessage]);
933 message.optionalNestedMessage = message.optionalNestedMessage;
934 XCTAssertTrue([message hasOptionalNestedMessage]);
939 TestRecursiveMessage *message;
945 message = [[TestRecursiveMessage alloc] init];
946 messageLevel1 = [message.a retain];
947 messageLevel2 = [message.a.a retain];
948 messageLevel3 = [message.a.a.a retain];
949 messageLevel4 = [message.a.a.a.a retain];
950 message.a.i = 1;
953 XCTAssertEqual(message.retainCount, (NSUInteger)1);
954 [message release];
966 // Basic tests for default creation of arrays in a message.
967 TestRecursiveMessageWithRepeatedField *message =
968 [TestRecursiveMessageWithRepeatedField message];
970 [TestRecursiveMessageWithRepeatedField message];
973 XCTAssertNotNil(message.a.a.iArray);
974 XCTAssertFalse([message hasA]);
975 XCTAssertFalse([message.a hasA]);
981 [message.a.a.iArray addValue:42];
982 XCTAssertTrue([message hasA]);
983 XCTAssertTrue([message.a hasA]);
984 XCTAssertEqual([message.a.a.iArray count], (NSUInteger)1);
994 [TestRecursiveMessageWithRepeatedField message];
996 [TestRecursiveMessageWithRepeatedField message];
1006 [TestRecursiveMessageWithRepeatedField message];
1008 [TestRecursiveMessageWithRepeatedField message];
1020 TestAllTypes *message = [TestAllTypes message];
1021 XCTAssertNotNil(message.repeatedStringArray);
1022 XCTAssertNotNil(message.repeatedInt32Array);
1023 TestAllTypes *message2 = [[message copy] autorelease];
1025 XCTAssertNotEqual(message.repeatedStringArray, message2.repeatedStringArray);
1026 XCTAssertNotEqual(message.repeatedInt32Array, message2.repeatedInt32Array);
1030 TestAllTypes *message3 = [TestAllTypes message];
1033 XCTAssertNotNil(message.repeatedInt32Array);
1034 XCTAssertNotNil(message.repeatedStringArray);
1046 TestAllTypes *message = [TestAllTypes message];
1049 TestAllTypes *message2 = [TestAllTypes message];
1050 message.repeatedInt32Array = message2.repeatedInt32Array;
1051 message.repeatedStringArray = message2.repeatedStringArray;
1053 XCTAssertEqual(message.repeatedInt32Array->_autocreator, message2);
1054 XCTAssertTrue([message.repeatedStringArray
1057 ((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator,
1061 XCTAssertNil(message.repeatedInt32Array->_autocreator);
1063 [message.repeatedStringArray isKindOfClass:[GPBAutocreatedArray class]]);
1065 ((GPBAutocreatedArray *)message.repeatedStringArray)->_autocreator);
1070 TestAllTypes *message = [TestAllTypes message];
1071 GPBInt32Array *repeatedInt32Array = [message.repeatedInt32Array retain];
1073 (GPBAutocreatedArray *)[message.repeatedStringArray retain];
1075 XCTAssertEqual(repeatedInt32Array->_autocreator, message);
1076 XCTAssertEqual(repeatedStringArray->_autocreator, message);
1077 message.repeatedInt32Array = nil;
1078 message.repeatedStringArray = nil;
1089 TestRecursiveMessageWithRepeatedField *message =
1090 [TestRecursiveMessageWithRepeatedField message];
1091 XCTAssertNotNil(message.a);
1092 XCTAssertNotNil(message.a.iArray);
1093 XCTAssertFalse([message hasA]);
1094 GPBInt32Array *iArray = [message.a.iArray retain];
1095 XCTAssertEqual(iArray->_autocreator, message.a); // Pointer comparision
1096 message.a.iArray = [GPBInt32Array arrayWithValue:1];
1097 XCTAssertTrue([message hasA]);
1098 XCTAssertNotEqual(message.a.iArray, iArray); // Pointer comparision
1104 TestRecursiveMessageWithRepeatedField *message =
1105 [TestRecursiveMessageWithRepeatedField message];
1106 XCTAssertNotNil(message.a);
1107 XCTAssertNotNil(message.a.strArray);
1108 XCTAssertFalse([message hasA]);
1110 (GPBAutocreatedArray *)[message.a.strArray retain];
1112 XCTAssertEqual(strArray->_autocreator, message.a); // Pointer comparision
1113 message.a.strArray = [NSMutableArray arrayWithObject:@"foo"];
1114 XCTAssertTrue([message hasA]);
1115 XCTAssertNotEqual(message.a.strArray, strArray); // Pointer comparision
1124 TestRecursiveMessageWithRepeatedField *message =
1125 [TestRecursiveMessageWithRepeatedField message];
1126 XCTAssertNotNil(message.a);
1127 XCTAssertNotNil(message.a.iArray);
1128 XCTAssertFalse([message hasA]);
1129 message.a.iArray = message.a.iArray;
1130 XCTAssertTrue([message hasA]);
1131 XCTAssertNil(message.a.iArray->_autocreator);
1135 TestRecursiveMessageWithRepeatedField *message =
1136 [TestRecursiveMessageWithRepeatedField message];
1137 XCTAssertNotNil(message.a);
1138 XCTAssertNotNil(message.a.strArray);
1139 XCTAssertFalse([message hasA]);
1140 message.a.strArray = message.a.strArray;
1141 XCTAssertTrue([message hasA]);
1142 XCTAssertTrue([message.a.strArray isKindOfClass:[GPBAutocreatedArray class]]);
1143 XCTAssertNil(((GPBAutocreatedArray *)message.a.strArray)->_autocreator);
1150 TestRecursiveMessageWithRepeatedField *message =
1151 [TestRecursiveMessageWithRepeatedField message];
1152 [message.a.iArray removeAll];
1153 XCTAssertFalse([message hasA]);
1154 [message.a.strArray removeAllObjects];
1155 XCTAssertFalse([message hasA]);
1159 // Basic tests for default creation of maps in a message.
1160 TestRecursiveMessageWithRepeatedField *message =
1161 [TestRecursiveMessageWithRepeatedField message];
1163 [TestRecursiveMessageWithRepeatedField message];
1166 XCTAssertNotNil(message.a.a.iToI);
1167 XCTAssertFalse([message hasA]);
1168 XCTAssertFalse([message.a hasA]);
1174 [message.a.a.iToI setValue:100 forKey:200];
1175 XCTAssertTrue([message hasA]);
1176 XCTAssertTrue([message.a hasA]);
1177 XCTAssertEqual([message.a.a.iToI count], (NSUInteger)1);
1187 [TestRecursiveMessageWithRepeatedField message];
1189 [TestRecursiveMessageWithRepeatedField message];
1199 [TestRecursiveMessageWithRepeatedField message];
1201 [TestRecursiveMessageWithRepeatedField message];
1213 TestRecursiveMessageWithRepeatedField *message =
1214 [TestRecursiveMessageWithRepeatedField message];
1215 XCTAssertNotNil(message.strToStr);
1216 XCTAssertNotNil(message.iToI);
1218 [[message copy] autorelease];
1220 XCTAssertNotEqual(message.strToStr, message2.strToStr);
1221 XCTAssertNotEqual(message.iToI, message2.iToI);
1226 [TestRecursiveMessageWithRepeatedField message];
1230 XCTAssertNotNil(message.iToI);
1231 XCTAssertNotNil(message.iToI);
1242 TestRecursiveMessageWithRepeatedField *message =
1243 [TestRecursiveMessageWithRepeatedField message];
1247 [TestRecursiveMessageWithRepeatedField message];
1248 message.iToI = message2.iToI;
1249 message.strToStr = message2.strToStr;
1251 XCTAssertEqual(message.iToI->_autocreator, message2);
1252 XCTAssertTrue([message.strToStr
1255 ((GPBAutocreatedDictionary *)message.strToStr)->_autocreator,
1259 XCTAssertNil(message.iToI->_autocreator);
1261 [message.strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
1263 ((GPBAutocreatedDictionary *)message.strToStr)->_autocreator);
1268 TestRecursiveMessageWithRepeatedField *message =
1269 [TestRecursiveMessageWithRepeatedField message];
1270 GPBInt32Int32Dictionary *iToI = [message.iToI retain];
1272 (GPBAutocreatedDictionary *)[message.strToStr retain];
1274 XCTAssertEqual(iToI->_autocreator, message);
1275 XCTAssertEqual(strToStr->_autocreator, message);
1276 message.iToI = nil;
1277 message.strToStr = nil;
1288 TestRecursiveMessageWithRepeatedField *message =
1289 [TestRecursiveMessageWithRepeatedField message];
1290 XCTAssertNotNil(message.a);
1291 XCTAssertNotNil(message.a.iToI);
1292 XCTAssertFalse([message hasA]);
1293 GPBInt32Int32Dictionary *iToI = [message.a.iToI retain];
1294 XCTAssertEqual(iToI->_autocreator, message.a); // Pointer comparision
1295 message.a.iToI = [GPBInt32Int32Dictionary dictionaryWithValue:6 forKey:7];
1296 XCTAssertTrue([message hasA]);
1297 XCTAssertNotEqual(message.a.iToI, iToI); // Pointer comparision
1303 TestRecursiveMessageWithRepeatedField *message =
1304 [TestRecursiveMessageWithRepeatedField message];
1305 XCTAssertNotNil(message.a);
1306 XCTAssertNotNil(message.a.strToStr);
1307 XCTAssertFalse([message hasA]);
1309 (GPBAutocreatedDictionary *)[message.a.strToStr retain];
1311 XCTAssertEqual(strToStr->_autocreator, message.a); // Pointer comparision
1312 message.a.strToStr =
1314 XCTAssertTrue([message hasA]);
1315 XCTAssertNotEqual(message.a.strToStr, strToStr); // Pointer comparision
1324 TestRecursiveMessageWithRepeatedField *message =
1325 [TestRecursiveMessageWithRepeatedField message];
1326 XCTAssertNotNil(message.a);
1327 XCTAssertNotNil(message.a.iToI);
1328 XCTAssertFalse([message hasA]);
1329 message.a.iToI = message.a.iToI;
1330 XCTAssertTrue([message hasA]);
1331 XCTAssertNil(message.a.iToI->_autocreator);
1335 TestRecursiveMessageWithRepeatedField *message =
1336 [TestRecursiveMessageWithRepeatedField message];
1337 XCTAssertNotNil(message.a);
1338 XCTAssertNotNil(message.a.strToStr);
1339 XCTAssertFalse([message hasA]);
1340 message.a.strToStr = message.a.strToStr;
1341 XCTAssertTrue([message hasA]);
1342 XCTAssertTrue([message.a.strToStr isKindOfClass:[GPBAutocreatedDictionary class]]);
1343 XCTAssertNil(((GPBAutocreatedDictionary *)message.a.strToStr)->_autocreator);
1349 TestRecursiveMessageWithRepeatedField *message =
1350 [TestRecursiveMessageWithRepeatedField message];
1351 [message.a.iToI removeAll];
1352 XCTAssertFalse([message hasA]);
1353 [message.a.strToStr removeAllObjects];
1354 XCTAssertFalse([message hasA]);
1358 TestAllExtensions *message = [TestAllExtensions message];
1359 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1360 [self assertAllExtensionsSet:message repeatedCount:kGPBDefaultRepeatCount];
1364 TestAllExtensions *message = [TestAllExtensions message];
1365 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1366 [self modifyRepeatedExtensions:message];
1367 [self assertRepeatedExtensionsModified:message
1372 [self assertExtensionsClear:[TestAllExtensions message]];
1376 TestAllExtensions *message = [TestAllExtensions message];
1377 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1378 [self modifyRepeatedExtensions:message];
1379 TestAllExtensions *message2 = [TestAllExtensions message];
1381 XCTAssertFalse([message isEqual:message2]);
1382 message2 = [TestAllExtensions message];
1385 XCTAssertEqualObjects(message, message2);
1389 TestAllExtensions *message = [TestAllExtensions message];
1390 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1391 [self modifyRepeatedExtensions:message];
1393 message = [TestAllExtensions message];
1394 [self setAllExtensions:message repeatedCount:kGPBDefaultRepeatCount];
1395 TestAllExtensions *message2 = [TestAllExtensions message];
1397 [message2 mergeFrom:message];
1399 XCTAssertEqualObjects(message, message2);
1403 TestAllExtensions *message = [TestAllExtensions message];
1407 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1408 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1410 [message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
1412 [message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
1414 [message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
1415 XCTAssertFalse([message
1418 [message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
1423 [message getExtension:[UnittestRoot optionalGroupExtension]];
1425 [message getExtension:[UnittestRoot optionalNestedMessageExtension]];
1427 [message getExtension:[UnittestRoot optionalForeignMessageExtension]];
1429 [message getExtension:[UnittestRoot optionalImportMessageExtension]];
1430 PublicImportMessage *optionalPublicImportMessage = [message
1433 [message getExtension:[UnittestRoot optionalLazyMessageExtension]];
1445 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1446 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1447 XCTAssertFalse([message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
1448 XCTAssertFalse([message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
1449 XCTAssertFalse([message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
1450 XCTAssertFalse([message hasExtension:[UnittestRoot optionalPublicImportMessageExtension]]);
1451 XCTAssertFalse([message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
1453 // And they set that value back in to the message since the value created was
1456 XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]],
1459 [message getExtension:[UnittestRoot optionalNestedMessageExtension]],
1462 [message getExtension:[UnittestRoot optionalForeignMessageExtension]],
1465 [message getExtension:[UnittestRoot optionalImportMessageExtension]],
1468 [message getExtension:[UnittestRoot optionalPublicImportMessageExtension]],
1471 [message getExtension:[UnittestRoot optionalLazyMessageExtension]],
1474 // And the default objects for a second message should be distinct (again,
1477 TestAllExtensions *message2 = [TestAllExtensions message];
1501 [message setExtension:[UnittestRoot optionalGroupExtension] value:nil];
1502 [message setExtension:[UnittestRoot optionalGroupExtension] value:nil];
1503 [message setExtension:[UnittestRoot optionalNestedMessageExtension]
1505 [message setExtension:[UnittestRoot optionalForeignMessageExtension]
1507 [message setExtension:[UnittestRoot optionalImportMessageExtension]
1509 [message setExtension:[UnittestRoot optionalPublicImportMessageExtension]
1511 [message setExtension:[UnittestRoot optionalLazyMessageExtension] value:nil];
1513 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1514 XCTAssertFalse([message hasExtension:[UnittestRoot optionalGroupExtension]]);
1516 [message hasExtension:[UnittestRoot optionalNestedMessageExtension]]);
1518 [message hasExtension:[UnittestRoot optionalForeignMessageExtension]]);
1520 [message hasExtension:[UnittestRoot optionalImportMessageExtension]]);
1521 XCTAssertFalse([message
1524 [message hasExtension:[UnittestRoot optionalLazyMessageExtension]]);
1526 XCTAssertEqual([message getExtension:[UnittestRoot optionalGroupExtension]],
1529 [message getExtension:[UnittestRoot optionalNestedMessageExtension]],
1532 [message getExtension:[UnittestRoot optionalForeignMessageExtension]],
1535 [message getExtension:[UnittestRoot optionalImportMessageExtension]],
1538 [message
1542 [message getExtension:[UnittestRoot optionalLazyMessageExtension]],
1549 TestAllExtensions *message = [TestAllExtensions message];
1550 TestAllExtensions *message2 = [TestAllExtensions message];
1552 [message setExtension:extension value:[message2 getExtension:extension]];
1553 XCTAssertEqual([message getExtension:extension],
1556 XCTAssertTrue([message hasExtension:extension]);
1562 XCTAssertTrue([message hasExtension:extension]);
1567 TestAllExtensions *message = [TestAllExtensions message];
1573 [message getExtension:optionalGroupExtension];
1576 XCTAssertNotNil([message getExtension:optionalNestedMessageExtesion]);
1577 XCTAssertTrue([message hasExtension:optionalGroupExtension]);
1578 XCTAssertFalse([message hasExtension:optionalNestedMessageExtesion]);
1580 TestAllExtensions *message2 = [[message copy] autorelease];
1584 XCTAssertEqualObjects([message getExtension:optionalGroupExtension],
1587 XCTAssertNotEqual([message getExtension:optionalGroupExtension],
1593 XCTAssertNotEqual([message getExtension:optionalNestedMessageExtesion],
1599 TestAllExtensions *message = [TestAllExtensions message];
1603 [[message getExtension:optionalGroupExtension] retain];
1604 [message clear];
1606 [message getExtension:optionalGroupExtension];
1616 TestAllExtensions *message = [TestAllExtensions message];
1621 TestAllExtensions *message2 = [TestAllExtensions message];
1622 [message setExtension:optionalGroupExtension
1625 [message getExtension:optionalGroupExtension], message2));
1629 [message getExtension:optionalGroupExtension], message));
1634 TestAllExtensions *message = [TestAllExtensions message];
1638 [[message getExtension:optionalGroupExtension] retain];
1639 [message clearExtension:optionalGroupExtension];
1641 [message getExtension:optionalGroupExtension];
1643 XCTAssertFalse([message hasExtension:optionalGroupExtension]);
1650 TestAllExtensions *message_lvl2 = [message getExtension:recursiveExtension];
1654 XCTAssertFalse([message hasExtension:recursiveExtension]);
1660 TestAllExtensions *message = [TestAllExtensions message];
1663 TestAllExtensions *message_lvl2 = [message getExtension:recursiveExtension];
1668 XCTAssertFalse([message hasExtension:recursiveExtension]);
1673 XCTAssertTrue([message hasExtension:recursiveExtension]);
1679 XCTAssertFalse(GPBWasMessageAutocreatedBy(message_lvl2, message));
1684 TestAllExtensions *message = [TestAllExtensions message];
1687 XCTAssertNotNil([message getExtension:optionalGroupExtension]);
1688 XCTAssertFalse([message hasExtension:optionalGroupExtension]);
1689 [message setExtension:optionalGroupExtension
1690 value:[message getExtension:optionalGroupExtension]];
1691 XCTAssertTrue([message hasExtension:optionalGroupExtension]);
1699 TestAllExtensions *message;
1704 message = [[TestAllExtensions alloc] init];
1705 message_lvl2 = [[message getExtension:recursiveExtension] retain];
1712 XCTAssertEqual(message.retainCount, (NSUInteger)1);
1714 [message release];
1732 TestAllExtensions *message;
1734 message = [[TestAllExtensions alloc] init];
1735 [message getExtension:recursiveExtension];
1740 [message setExtension:recursiveExtension
1741 value:[message getExtension:recursiveExtension]];
1742 XCTAssertTrue([message hasExtension:recursiveExtension]);
1743 [message release];
1747 TestRecursiveMessage *message = [TestRecursiveMessage message];
1748 XCTAssertNotNil(message.a);
1749 XCTAssertNotNil(message.a.a);
1750 XCTAssertEqual(message.a.a.i, 0);
1757 GPBMessage *message = [GPBMessage message];
1758 [message setUnknownFields:unknowns];
1759 NSData *data = [message data];
1762 XCTAssertEqualObjects(message, message2);
1769 GPBMessage *message1 = [GPBMessage message];
1776 GPBMessage *message2 = [GPBMessage message];
1799 ObjcWeirdDefaults *message = [ObjcWeirdDefaults message];
1800 GPBDescriptor *descriptor = [[message class] descriptor];
1804 XCTAssertFalse(message.hasFoo);
1805 XCTAssertEqualObjects(message.foo, @"");
1810 XCTAssertFalse(message.hasBar);
1811 XCTAssertEqualObjects(message.bar, GPBEmptyNSData());
1829 ObjCPropertyNaming *msg = [ObjCPropertyNaming message];
1892 EnumTestMsg *msg = [EnumTestMsg message];
1953 MessageWithOneBasedEnum *enumMsg = [MessageWithOneBasedEnum message];
1961 BoolOnlyMessage *msg1 = [BoolOnlyMessage message];
1962 BoolOnlyMessage *msg2 = [BoolOnlyMessage message];