Skip to content

Commit aefe47c

Browse files
thomasvlcopybara-github
authored andcommitted
[ObjC] Add a test for unknown runtime markers.
PiperOrigin-RevId: 740876067
1 parent c217413 commit aefe47c

File tree

4 files changed

+259
-0
lines changed

4 files changed

+259
-0
lines changed

objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
F40EE4C0206BF8B90071091A /* GPBCompileTest22.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE48A206BF8B00071091A /* GPBCompileTest22.m */; };
6060
F40EE4C1206BF8B90071091A /* GPBCompileTest23.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE487206BF8B00071091A /* GPBCompileTest23.m */; };
6161
F41C175D1833D3310064ED4D /* GPBPerfTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F41C175C1833D3310064ED4D /* GPBPerfTests.m */; };
62+
F42D5F3C2D9478B400E136F5 /* GPBMessageBadVersionFormatTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F42D5F3B2D9478B400E136F5 /* GPBMessageBadVersionFormatTest.m */; };
6263
F4353D1D1AB8822D005A6198 /* GPBDescriptorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */; };
6364
F4353D231ABB1537005A6198 /* GPBDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D211ABB1537005A6198 /* GPBDictionary.m */; };
6465
F4353D341AC06F10005A6198 /* GPBDictionaryTests+Bool.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D2D1AC06F10005A6198 /* GPBDictionaryTests+Bool.m */; };
@@ -197,6 +198,7 @@
197198
F40EE492206BF8B10071091A /* GPBCompileTest06.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest06.m; sourceTree = "<group>"; };
198199
F40EE493206BF8B20071091A /* GPBCompileTest11.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest11.m; sourceTree = "<group>"; };
199200
F41C175C1833D3310064ED4D /* GPBPerfTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBPerfTests.m; sourceTree = "<group>"; };
201+
F42D5F3B2D9478B400E136F5 /* GPBMessageBadVersionFormatTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GPBMessageBadVersionFormatTest.m; sourceTree = "<group>"; };
200202
F4353D1C1AB8822D005A6198 /* GPBDescriptorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDescriptorTests.m; sourceTree = "<group>"; };
201203
F4353D201ABB1537005A6198 /* GPBDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBDictionary.h; sourceTree = "<group>"; };
202204
F4353D211ABB1537005A6198 /* GPBDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionary.m; sourceTree = "<group>"; };
@@ -505,6 +507,7 @@
505507
F4487C821AAF6AB300531423 /* GPBMessageTests+Merge.m */,
506508
F4487C741AADF7F500531423 /* GPBMessageTests+Runtime.m */,
507509
F4487C7E1AAF62CD00531423 /* GPBMessageTests+Serialization.m */,
510+
F42D5F3B2D9478B400E136F5 /* GPBMessageBadVersionFormatTest.m */,
508511
F4629E4A2D35AB0700C1E352 /* GPBMessage30007FormatTest.m */,
509512
F45BFEDD2D67AE0B00D2224A /* GPBMessage40310FormatTest.m */,
510513
F4CDDDF12D94631A007DE962 /* GPBMessage40311FormatTest.m */,
@@ -762,6 +765,7 @@
762765
F40EE4B4206BF8B90071091A /* GPBCompileTest10.m in Sources */,
763766
F4353D361AC06F10005A6198 /* GPBDictionaryTests+Int64.m in Sources */,
764767
F4A92AFD2B88E105001E4F69 /* GPBCompileTest24.m in Sources */,
768+
F42D5F3C2D9478B400E136F5 /* GPBMessageBadVersionFormatTest.m in Sources */,
765769
F40EE4C0206BF8B90071091A /* GPBCompileTest22.m in Sources */,
766770
F40EE4B2206BF8B90071091A /* GPBCompileTest08.m in Sources */,
767771
F40EE4BB206BF8B90071091A /* GPBCompileTest17.m in Sources */,

objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
F40EE505206BF91E0071091A /* GPBCompileTest22.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CF206BF9170071091A /* GPBCompileTest22.m */; };
6060
F40EE506206BF91E0071091A /* GPBCompileTest23.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CC206BF9170071091A /* GPBCompileTest23.m */; };
6161
F41C175D1833D3310064ED4D /* GPBPerfTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F41C175C1833D3310064ED4D /* GPBPerfTests.m */; };
62+
F42D5F402D9478E800E136F5 /* GPBMessageBadVersionFormatTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F42D5F3F2D9478E800E136F5 /* GPBMessageBadVersionFormatTest.m */; };
6263
F4353D1F1AB88243005A6198 /* GPBDescriptorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */; };
6364
F4353D271ABB156F005A6198 /* GPBDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D251ABB156F005A6198 /* GPBDictionary.m */; };
6465
F4353D421AC06F31005A6198 /* GPBDictionaryTests+Bool.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D3B1AC06F31005A6198 /* GPBDictionaryTests+Bool.m */; };
@@ -197,6 +198,7 @@
197198
F40EE4D7206BF9190071091A /* GPBCompileTest06.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest06.m; sourceTree = "<group>"; };
198199
F40EE4D8206BF9190071091A /* GPBCompileTest11.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest11.m; sourceTree = "<group>"; };
199200
F41C175C1833D3310064ED4D /* GPBPerfTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBPerfTests.m; sourceTree = "<group>"; };
201+
F42D5F3F2D9478E800E136F5 /* GPBMessageBadVersionFormatTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GPBMessageBadVersionFormatTest.m; sourceTree = "<group>"; };
200202
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDescriptorTests.m; sourceTree = "<group>"; };
201203
F4353D241ABB156F005A6198 /* GPBDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBDictionary.h; sourceTree = "<group>"; };
202204
F4353D251ABB156F005A6198 /* GPBDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionary.m; sourceTree = "<group>"; };
@@ -510,6 +512,7 @@
510512
F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */,
511513
F4487C761AADF84900531423 /* GPBMessageTests+Runtime.m */,
512514
F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */,
515+
F42D5F3F2D9478E800E136F5 /* GPBMessageBadVersionFormatTest.m */,
513516
F4629E4C2D35AB4600C1E352 /* GPBMessage30007FormatTest.m */,
514517
F45BFEDB2D67ADE900D2224A /* GPBMessage40310FormatTest.m */,
515518
F4CDDDEF2D9462FC007DE962 /* GPBMessage40311FormatTest.m */,
@@ -767,6 +770,7 @@
767770
F40EE4F9206BF91E0071091A /* GPBCompileTest10.m in Sources */,
768771
F4353D441AC06F31005A6198 /* GPBDictionaryTests+Int64.m in Sources */,
769772
F4A92AFF2B88E663001E4F69 /* GPBCompileTest24.m in Sources */,
773+
F42D5F402D9478E800E136F5 /* GPBMessageBadVersionFormatTest.m in Sources */,
770774
F40EE505206BF91E0071091A /* GPBCompileTest22.m in Sources */,
771775
F40EE4F7206BF91E0071091A /* GPBCompileTest08.m in Sources */,
772776
F40EE500206BF91E0071091A /* GPBCompileTest17.m in Sources */,

objectivec/ProtocolBuffers_tvOS.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
F40EE505206BF91E0071091A /* GPBCompileTest22.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CF206BF9170071091A /* GPBCompileTest22.m */; };
6060
F40EE506206BF91E0071091A /* GPBCompileTest23.m in Sources */ = {isa = PBXBuildFile; fileRef = F40EE4CC206BF9170071091A /* GPBCompileTest23.m */; };
6161
F41C175D1833D3310064ED4D /* GPBPerfTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F41C175C1833D3310064ED4D /* GPBPerfTests.m */; };
62+
F42D5F3E2D9478D000E136F5 /* GPBMessageBadVersionFormatTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F42D5F3D2D9478D000E136F5 /* GPBMessageBadVersionFormatTest.m */; };
6263
F4353D1F1AB88243005A6198 /* GPBDescriptorTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */; };
6364
F4353D271ABB156F005A6198 /* GPBDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D251ABB156F005A6198 /* GPBDictionary.m */; };
6465
F4353D421AC06F31005A6198 /* GPBDictionaryTests+Bool.m in Sources */ = {isa = PBXBuildFile; fileRef = F4353D3B1AC06F31005A6198 /* GPBDictionaryTests+Bool.m */; };
@@ -198,6 +199,7 @@
198199
F40EE4D7206BF9190071091A /* GPBCompileTest06.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest06.m; sourceTree = "<group>"; };
199200
F40EE4D8206BF9190071091A /* GPBCompileTest11.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBCompileTest11.m; sourceTree = "<group>"; };
200201
F41C175C1833D3310064ED4D /* GPBPerfTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBPerfTests.m; sourceTree = "<group>"; };
202+
F42D5F3D2D9478D000E136F5 /* GPBMessageBadVersionFormatTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GPBMessageBadVersionFormatTest.m; sourceTree = "<group>"; };
201203
F4353D1E1AB88243005A6198 /* GPBDescriptorTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDescriptorTests.m; sourceTree = "<group>"; };
202204
F4353D241ABB156F005A6198 /* GPBDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPBDictionary.h; sourceTree = "<group>"; };
203205
F4353D251ABB156F005A6198 /* GPBDictionary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GPBDictionary.m; sourceTree = "<group>"; };
@@ -511,6 +513,7 @@
511513
F4487C841AAF6AC500531423 /* GPBMessageTests+Merge.m */,
512514
F4487C761AADF84900531423 /* GPBMessageTests+Runtime.m */,
513515
F4487C801AAF62FC00531423 /* GPBMessageTests+Serialization.m */,
516+
F42D5F3D2D9478D000E136F5 /* GPBMessageBadVersionFormatTest.m */,
514517
F4629E4E2D35AB6200C1E352 /* GPBMessage30007FormatTest.m */,
515518
F45BFED92D67ADCD00D2224A /* GPBMessage40310FormatTest.m */,
516519
F4CDDDED2D9462CF007DE962 /* GPBMessage40311FormatTest.m */,
@@ -769,6 +772,7 @@
769772
F40EE4F9206BF91E0071091A /* GPBCompileTest10.m in Sources */,
770773
F4353D441AC06F31005A6198 /* GPBDictionaryTests+Int64.m in Sources */,
771774
F4A92B012B88E683001E4F69 /* GPBCompileTest24.m in Sources */,
775+
F42D5F3E2D9478D000E136F5 /* GPBMessageBadVersionFormatTest.m in Sources */,
772776
F40EE505206BF91E0071091A /* GPBCompileTest22.m in Sources */,
773777
F40EE4F7206BF91E0071091A /* GPBCompileTest08.m in Sources */,
774778
F40EE500206BF91E0071091A /* GPBCompileTest17.m in Sources */,
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
// Protocol Buffers - Google's data interchange format
2+
// Copyright 2025 Google Inc. All rights reserved.
3+
//
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file or at
6+
// https://developers.google.com/open-source/licenses/bsd
7+
8+
#import <stdatomic.h>
9+
10+
#import "GPBDescriptor_PackagePrivate.h"
11+
#import "GPBExtensionRegistry.h"
12+
#import "GPBMessage.h"
13+
#import "GPBProtocolBuffers_RuntimeSupport.h"
14+
#import "GPBRootObject_PackagePrivate.h"
15+
#import "GPBTestUtilities.h"
16+
17+
// This is a fake version, so the ptr check will fail.
18+
static const int32_t FAKE_GOOGLE_PROTOBUF_OBJC_EXPECTED_GENCODE_VERSION_40311 = 40311;
19+
20+
@interface MessageBadVersionFormatTest : GPBTestCase
21+
@end
22+
23+
// clang-format off
24+
// NOLINTBEGIN
25+
26+
// -------------------------------------------------------------------------------------------------
27+
//
28+
// This is extracted from generated code with the 40311 format but then edited so the pass in
29+
// unknown values for the version support, the original proto was as follows:
30+
//
31+
// syntax = "proto2";
32+
//
33+
// enum EnumBadVersion {
34+
// FOO = 0;
35+
// BAR = 1;
36+
// }
37+
//
38+
// message MessageBadVersion {
39+
// optional EnumBadVersion value = 1;
40+
// extensions 100 to max;
41+
// }
42+
//
43+
// extend MessageBadVersion {
44+
// optional MessageBadVersion other_m = 100;
45+
// optional EnumBadVersion other_e = 101;
46+
// }
47+
//
48+
// -------------------------------------------------------------------------------------------------
49+
50+
NS_ASSUME_NONNULL_BEGIN
51+
52+
typedef GPB_ENUM(EnumBadVersion) {
53+
EnumBadVersion_Foo = 0,
54+
EnumBadVersion_Bar = 1,
55+
};
56+
57+
GPBEnumDescriptor *EnumBadVersion_EnumDescriptor(void);
58+
59+
BOOL EnumBadVersion_IsValidValue(int32_t value);
60+
61+
GPB_FINAL @interface TestBadVersionRoot : GPBRootObject
62+
@end
63+
64+
@interface TestBadVersionRoot (DynamicMethods)
65+
+ (GPBExtensionDescriptor *)otherM;
66+
+ (GPBExtensionDescriptor *)otherE;
67+
@end
68+
69+
typedef GPB_ENUM(MessageBadVersion_FieldNumber) {
70+
MessageBadVersion_FieldNumber_Value = 1,
71+
};
72+
73+
GPB_FINAL @interface MessageBadVersion : GPBMessage
74+
75+
@property(nonatomic, readwrite) EnumBadVersion value;
76+
@property(nonatomic, readwrite) BOOL hasValue;
77+
78+
@end
79+
80+
NS_ASSUME_NONNULL_END
81+
82+
#pragma clang diagnostic push
83+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
84+
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
85+
86+
GPBObjCClassDeclaration(MessageBadVersion);
87+
88+
@implementation TestBadVersionRoot
89+
90+
+ (GPBExtensionRegistry*)extensionRegistry {
91+
// This is called by +initialize so there is no need to worry
92+
// about thread safety and initialization of registry.
93+
static GPBExtensionRegistry* registry = nil;
94+
if (!registry) {
95+
registry = [[GPBExtensionRegistry alloc] init];
96+
static GPBExtensionDescription descriptions[] = {
97+
{
98+
.defaultValue.valueMessage = nil,
99+
.singletonName = GPBStringifySymbol(TestBadVersionRoot) "_otherM",
100+
.extendedClass.clazz = GPBObjCClass(MessageBadVersion),
101+
.messageOrGroupClass.clazz = GPBObjCClass(MessageBadVersion),
102+
.enumDescriptorFunc = NULL,
103+
.fieldNumber = 100,
104+
.dataType = GPBDataTypeMessage,
105+
.options = GPBExtensionNone,
106+
},
107+
{
108+
.defaultValue.valueEnum = EnumBadVersion_Foo,
109+
.singletonName = GPBStringifySymbol(TestBadVersionRoot) "_otherE",
110+
.extendedClass.clazz = GPBObjCClass(MessageBadVersion),
111+
.messageOrGroupClass.clazz = Nil,
112+
.enumDescriptorFunc = EnumBadVersion_EnumDescriptor,
113+
.fieldNumber = 101,
114+
.dataType = GPBDataTypeEnum,
115+
.options = GPBExtensionNone,
116+
},
117+
};
118+
for (size_t i = 0; i < sizeof(descriptions) / sizeof(descriptions[0]); ++i) {
119+
GPBExtensionDescriptor *extension =
120+
[[GPBExtensionDescriptor alloc] initWithExtensionDescription:&descriptions[i]
121+
runtimeSupport:&FAKE_GOOGLE_PROTOBUF_OBJC_EXPECTED_GENCODE_VERSION_40311];
122+
[registry addExtension:extension];
123+
[self globallyRegisterExtension:extension];
124+
[extension release];
125+
}
126+
// None of the imports (direct or indirect) defined extensions, so no need to add
127+
// them to this registry.
128+
}
129+
return registry;
130+
}
131+
132+
@end
133+
134+
static GPBFilePackageAndPrefix TestBadVersionRoot_FileDescription = {
135+
.package = NULL,
136+
.prefix = NULL
137+
};
138+
139+
GPBEnumDescriptor *EnumBadVersion_EnumDescriptor(void) {
140+
static _Atomic(GPBEnumDescriptor*) descriptor = nil;
141+
if (!descriptor) {
142+
static const char *valueNames =
143+
"Foo\000Bar\000";
144+
static const int32_t values[] = {
145+
EnumBadVersion_Foo,
146+
EnumBadVersion_Bar,
147+
};
148+
GPBEnumDescriptor *worker =
149+
[GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol(EnumBadVersion)
150+
runtimeSupport:&FAKE_GOOGLE_PROTOBUF_OBJC_EXPECTED_GENCODE_VERSION_40311
151+
valueNames:valueNames
152+
values:values
153+
count:(uint32_t)(sizeof(values) / sizeof(int32_t))
154+
enumVerifier:EnumBadVersion_IsValidValue
155+
flags:GPBEnumDescriptorInitializationFlag_IsClosed];
156+
GPBEnumDescriptor *expected = nil;
157+
if (!atomic_compare_exchange_strong(&descriptor, &expected, worker)) {
158+
[worker release];
159+
}
160+
}
161+
return descriptor;
162+
}
163+
164+
BOOL EnumBadVersion_IsValidValue(int32_t value__) {
165+
switch (value__) {
166+
case EnumBadVersion_Foo:
167+
case EnumBadVersion_Bar:
168+
return YES;
169+
default:
170+
return NO;
171+
}
172+
}
173+
174+
#pragma mark - MessageBadVersion
175+
176+
@implementation MessageBadVersion
177+
178+
@dynamic hasValue, value;
179+
180+
typedef struct MessageBadVersion__storage_ {
181+
uint32_t _has_storage_[1];
182+
EnumBadVersion value;
183+
} MessageBadVersion__storage_;
184+
185+
+ (GPBDescriptor *)descriptor {
186+
static GPBDescriptor *descriptor = nil;
187+
if (!descriptor) {
188+
static GPBMessageFieldDescription fields[] = {
189+
{
190+
.name = "value",
191+
.dataTypeSpecific.enumDescFunc = EnumBadVersion_EnumDescriptor,
192+
.number = MessageBadVersion_FieldNumber_Value,
193+
.hasIndex = 0,
194+
.offset = (uint32_t)offsetof(MessageBadVersion__storage_, value),
195+
.flags = GPBFieldNone,
196+
.dataType = GPBDataTypeEnum,
197+
},
198+
};
199+
GPBDescriptor *localDescriptor =
200+
[GPBDescriptor allocDescriptorForClass:GPBObjCClass(MessageBadVersion)
201+
messageName:@"MessageBadVersion"
202+
runtimeSupport:&FAKE_GOOGLE_PROTOBUF_OBJC_EXPECTED_GENCODE_VERSION_40311
203+
fileDescription:&TestBadVersionRoot_FileDescription
204+
fields:fields
205+
fieldCount:(uint32_t)(sizeof(fields) / sizeof(GPBMessageFieldDescription))
206+
storageSize:sizeof(MessageBadVersion__storage_)
207+
flags:GPBDescriptorInitializationFlag_None];
208+
static const GPBExtensionRange ranges[] = {
209+
{ .start = 100, .end = 536870912 },
210+
};
211+
[localDescriptor setupExtensionRanges:ranges
212+
count:(uint32_t)(sizeof(ranges) / sizeof(GPBExtensionRange))];
213+
#if defined(DEBUG) && DEBUG
214+
NSAssert(descriptor == nil, @"Startup recursed!");
215+
#endif // DEBUG
216+
descriptor = localDescriptor;
217+
}
218+
return descriptor;
219+
}
220+
221+
@end
222+
223+
#pragma clang diagnostic pop
224+
225+
// NOLINTEND
226+
// clang-format on
227+
228+
// -------------------------------------------------------------------------------------------------
229+
230+
@implementation MessageBadVersionFormatTest
231+
232+
- (void)testMessageBadVersionFormat {
233+
// Calling each one should try to start it up and result in a throw for an unknown version marker.
234+
// Mostly this shouldn't happen as the symbol should be coming out of the runtime library so
235+
// things should result in a link error before getting to the runtime check; this is just an added
236+
// safety check.
237+
XCTAssertThrowsSpecificNamed(EnumBadVersion_EnumDescriptor(), NSException,
238+
NSInternalInconsistencyException);
239+
240+
XCTAssertThrowsSpecificNamed([TestBadVersionRoot otherM], NSException,
241+
NSInternalInconsistencyException);
242+
243+
XCTAssertThrowsSpecificNamed([MessageBadVersion class], NSException,
244+
NSInternalInconsistencyException);
245+
}
246+
247+
@end

0 commit comments

Comments
 (0)