77
88syntax = "proto2" ;
99
10+ package objc.protobuf.tests ;
11+
1012import "google/protobuf/any.proto" ;
1113import "objectivec/Tests/unittest.proto" ;
1214
13- package objc.protobuf.tests ;
14-
1515// Explicit empty prefix, tests some validations code paths also.
1616option objc_class_prefix = "" ;
1717
@@ -78,143 +78,142 @@ message self {
7878 }
7979
8080 enum autorelease {
81- retain = 1 ;
82- release = 2 ;
81+ retain = 1 ;
82+ release = 2 ;
8383 retainCount = 3 ;
8484 }
8585
8686 // Singular
8787 // Objective C Keywords
88- optional bool id = 1 ;
89- optional bool _cmd = 2 ;
88+ optional bool id = 1 ;
89+ optional bool _cmd = 2 ;
9090 // super is used as submessage above
91- optional bool in = 4 ;
92- optional bool out = 5 ;
93- optional bool inout = 6 ;
94- optional bool bycopy = 7 ;
95- optional bool byref = 8 ;
96- optional bool oneway = 9 ;
97- optional bool self = 10 ;
98- optional bool instancetype = 11 ;
99- optional bool nullable = 12 ;
100- optional bool nonnull = 13 ;
101- optional bool nil = 14 ;
91+ optional bool in = 4 ;
92+ optional bool out = 5 ;
93+ optional bool inout = 6 ;
94+ optional bool bycopy = 7 ;
95+ optional bool byref = 8 ;
96+ optional bool oneway = 9 ;
97+ optional bool self = 10 ;
98+ optional bool instancetype = 11 ;
99+ optional bool nullable = 12 ;
100+ optional bool nonnull = 13 ;
101+ optional bool nil = 14 ;
102102 // Nil and nil can't be in the same message
103- optional bool YES = 16 ;
104- optional bool NO = 17 ;
105- optional bool weak = 18 ;
103+ optional bool YES = 16 ;
104+ optional bool NO = 17 ;
105+ optional bool weak = 18 ;
106106
107107 // Some C/C++ Keywords
108- optional bool case = 30 ;
109- optional bool if = 31 ;
110- optional bool and_eq = 32 ;
111- optional bool public = 33 ;
112- optional bool private = 34 ;
113- optional bool typename = 35 ;
114- optional bool static_cast = 36 ;
115- optional bool typeof = 37 ;
116- optional bool restrict = 38 ;
117- optional bool NULL = 39 ;
108+ optional bool case = 30 ;
109+ optional bool if = 31 ;
110+ optional bool and_eq = 32 ;
111+ optional bool public = 33 ;
112+ optional bool private = 34 ;
113+ optional bool typename = 35 ;
114+ optional bool static_cast = 36 ;
115+ optional bool typeof = 37 ;
116+ optional bool restrict = 38 ;
117+ optional bool NULL = 39 ;
118118
119119 // Some NSObject Methods
120- optional bool dealloc = 110 ;
121- optional bool isProxy = 111 ;
122- optional bool copy = 112 ;
123- optional bool description = 113 ;
124- optional bool zone = 114 ;
125- optional bool className = 115 ;
126- optional bool __retain_OA = 116 ;
127- optional bool CAMLType = 117 ;
128- optional bool isNSDictionary__ = 118 ;
120+ optional bool dealloc = 110 ;
121+ optional bool isProxy = 111 ;
122+ optional bool copy = 112 ;
123+ optional bool description = 113 ;
124+ optional bool zone = 114 ;
125+ optional bool className = 115 ;
126+ optional bool __retain_OA = 116 ;
127+ optional bool CAMLType = 117 ;
128+ optional bool isNSDictionary__ = 118 ;
129129 optional bool accessibilityLabel = 119 ;
130130
131131 // Some Objc "keywords" that we shouldn't
132132 // have to worry about because they
133133 // can only appear in specialized areas.
134- optional bool assign = 200 ;
135- optional bool getter = 201 ;
136- optional bool setter = 202 ;
137- optional bool atomic = 203 ;
138- optional bool nonatomic = 204 ;
139- optional bool strong = 205 ;
140- optional bool null_resettable = 206 ;
141- optional bool readonly = 207 ;
134+ optional bool assign = 200 ;
135+ optional bool getter = 201 ;
136+ optional bool setter = 202 ;
137+ optional bool atomic = 203 ;
138+ optional bool nonatomic = 204 ;
139+ optional bool strong = 205 ;
140+ optional bool null_resettable = 206 ;
141+ optional bool readonly = 207 ;
142142
143143 // Some GPBMessage methods
144- optional bool clear = 300 ;
145- optional bool data = 301 ;
146- optional bool descriptor = 302 ;
147- optional bool delimitedData = 303 ;
144+ optional bool clear = 300 ;
145+ optional bool data = 301 ;
146+ optional bool descriptor = 302 ;
147+ optional bool delimitedData = 303 ;
148148
149149 // Some MacTypes
150- optional bool Fixed = 400 ;
151- optional bool Point = 401 ;
152- optional bool FixedPoint = 402 ;
153- optional bool Style = 403 ;
150+ optional bool Fixed = 400 ;
151+ optional bool Point = 401 ;
152+ optional bool FixedPoint = 402 ;
153+ optional bool Style = 403 ;
154154
155155 // C/C++ reserved identifiers
156- optional bool _Generic = 500 ;
157- optional bool __block = 501 ;
156+ optional bool _Generic = 500 ;
157+ optional bool __block = 501 ;
158158
159159 // Try a keyword as a type
160- optional autorelease SubEnum = 1000 ;
160+ optional autorelease SubEnum = 1000 ;
161161
162162 optional group New = 2000 {
163- optional string copy = 1;
163+ optional string copy = 1;
164164 }
165165 optional group MutableCopy = 2001 {
166166 optional int32 extensionRegistry = 1;
167167 }
168168
169169 extensions 3000 to 3999;
170-
171170}
172171
173172enum retain {
174- count = 4 ;
175- initialized = 5 ;
173+ count = 4 ;
174+ initialized = 5 ;
176175 serializedSize = 6 ;
177176}
178177
179178message ObjCPropertyNaming {
180179 // Test that the properties properly get things all caps.
181- optional string url = 1 ;
180+ optional string url = 1 ;
182181 optional string thumbnail_url = 2 ;
183- optional string url_foo = 3 ;
182+ optional string url_foo = 3 ;
184183 optional string some_url_blah = 4 ;
185- optional string http = 5 ;
186- optional string https = 6 ;
184+ optional string http = 5 ;
185+ optional string https = 6 ;
187186 // This one doesn't.
188- repeated string urls = 7 ;
187+ repeated string urls = 7 ;
189188}
190189
191190// EnumValueShortName: The short names shouldn't get suffixes/prefixes.
192191enum Foo {
193192 SERIALIZED_SIZE = 1 ;
194- SIZE = 2 ;
195- OTHER = 3 ;
193+ SIZE = 2 ;
194+ OTHER = 3 ;
196195}
197196
198197// EnumValueShortName: The enum name gets a prefix.
199198enum Category {
200- RED = 1 ;
199+ RED = 1 ;
201200 BLUE = 2 ;
202201}
203202
204203// EnumValueShortName: Twist case, full name gets PB, but the short names
205204// should still end up correct.
206205enum Time {
207- BASE = 1 ;
208- RECORD = 2 ;
209- SOMETHING_ELSE = 3 ;
206+ BASE = 1 ;
207+ RECORD = 2 ;
208+ SOMETHING_ELSE = 3 ;
210209}
211210
212211extend self {
213- repeated int32 debugDescription = 3000 [packed = true ];
214- repeated int64 finalize = 3001 [packed = true ];
215- repeated uint32 hash = 3002 [packed = true ];
216- repeated uint64 classForCoder = 3003 [packed = true ];
217- repeated sint32 byref = 3004 [packed = true ];
212+ repeated int32 debugDescription = 3000 [packed = true ];
213+ repeated int64 finalize = 3001 [packed = true ];
214+ repeated uint32 hash = 3002 [packed = true ];
215+ repeated uint64 classForCoder = 3003 [packed = true ];
216+ repeated sint32 byref = 3004 [packed = true ];
218217}
219218
220219// Test handing of fields that start with init*.
@@ -700,13 +699,17 @@ message JustToScopeExtensions {
700699
701700 repeated string mutableCopy_val_lower_complex_repeated = 2711 ;
702701 repeated string mutableCopy_Val_upper_complex_repeated = 2712 ;
703- repeated string mutableCopyvalue_lower_no_underscore_complex_repeated = 2713 ;
704- repeated string mutableCopyValue_upper_no_underscore_complex_repeated = 2714 ;
702+ repeated string mutableCopyvalue_lower_no_underscore_complex_repeated =
703+ 2713;
704+ repeated string mutableCopyValue_upper_no_underscore_complex_repeated =
705+ 2714;
705706
706707 repeated int32 mutableCopy_val_lower_primitive_repeated = 2715 ;
707708 repeated int32 mutableCopy_Val_upper_primitive_repeated = 2716 ;
708- repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated = 2717 ;
709- repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated = 2718 ;
709+ repeated int32 mutableCopyvalue_lower_no_underscore_primitive_repeated =
710+ 2717;
711+ repeated int32 mutableCopyValue_upper_no_underscore_primitive_repeated =
712+ 2718;
710713
711714 repeated self mutableCopy_val_lower_message_repeated = 2719 ;
712715 repeated self mutableCopy_Val_upper_message_repeated = 2720 ;
@@ -781,9 +784,9 @@ message ObjcWeirdDefaults {
781784// Used to confirm negative enum values work as expected.
782785message EnumTestMsg {
783786 enum MyEnum {
784- ZERO = 0 ;
785- ONE = 1 ;
786- TWO = 2 ;
787+ ZERO = 0 ;
788+ ONE = 1 ;
789+ TWO = 2 ;
787790 NEG_ONE = -1 ;
788791 NEG_TWO = -2 ;
789792 }
@@ -794,6 +797,20 @@ message EnumTestMsg {
794797 repeated MyEnum mumble = 4 ;
795798}
796799
800+ message EnumTestMsgPrime {
801+ enum MyEnumPrime {
802+ ZERO = 0 ;
803+ ONE = 1 ;
804+ NEG_ONE = -1 ;
805+ // Lacks 2, -2.
806+ }
807+ optional MyEnumPrime foo = 1 ;
808+ optional MyEnumPrime bar = 2 [default = ONE ];
809+ optional MyEnumPrime baz = 3 [default = NEG_ONE ];
810+
811+ repeated MyEnumPrime mumble = 4 ;
812+ }
813+
797814// Test case for https://github.com/protocolbuffers/protobuf/issues/1453
798815// Message with no explicit defaults, but a non zero default for an enum.
799816message MessageWithOneBasedEnum {
0 commit comments