aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec/Tests/GPBDescriptorTests.m
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2016-08-16 11:26:49 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2016-09-08 11:59:57 -0400
commit337ec3065f98d6f048f92b3a864f65383a2549d8 (patch)
tree23ab2fea2b0d97cc64b0253fd313ce9bad1bbaf9 /objectivec/Tests/GPBDescriptorTests.m
parent4bc16578537495b5ee010d89f2909858312210ac (diff)
Add ObjC helpers for Any WKT.
- Capture the ObjC prefix used when generating the the file. - Track the containing type on descriptors. - Mark descriptors where the message class name got a suffix added to it. - Expose a fullName property on Descriptors. - Add helpers for packing/unpacking Any messages. - Bump the ObjC runtime version number. Since we added methods and invoke them in the generated code, ensure the code is running against a matching version. Otherwise, someone could compile against headers, but run with a framework that is older and get unknown selector failures. This should trip clearer messaging. Fixes https://github.com/google/protobuf/issues/1674
Diffstat (limited to 'objectivec/Tests/GPBDescriptorTests.m')
-rw-r--r--objectivec/Tests/GPBDescriptorTests.m29
1 files changed, 29 insertions, 0 deletions
diff --git a/objectivec/Tests/GPBDescriptorTests.m b/objectivec/Tests/GPBDescriptorTests.m
index 74e3172b..1e1c3de8 100644
--- a/objectivec/Tests/GPBDescriptorTests.m
+++ b/objectivec/Tests/GPBDescriptorTests.m
@@ -34,12 +34,41 @@
#import "GPBDescriptor.h"
#import "google/protobuf/Unittest.pbobjc.h"
+#import "google/protobuf/UnittestObjc.pbobjc.h"
+#import "google/protobuf/Descriptor.pbobjc.h"
@interface DescriptorTests : GPBTestCase
@end
@implementation DescriptorTests
+- (void)testDescriptor_containingType {
+ GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
+ GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
+ XCTAssertNil(testAllTypesDesc.containingType);
+ XCTAssertNotNil(nestedMessageDesc.containingType);
+ XCTAssertEqual(nestedMessageDesc.containingType, testAllTypesDesc); // Ptr comparison
+}
+
+- (void)testDescriptor_fullName {
+ GPBDescriptor *testAllTypesDesc = [TestAllTypes descriptor];
+ XCTAssertEqualObjects(testAllTypesDesc.fullName, @"protobuf_unittest.TestAllTypes");
+ GPBDescriptor *nestedMessageDesc = [TestAllTypes_NestedMessage descriptor];
+ XCTAssertEqualObjects(nestedMessageDesc.fullName, @"protobuf_unittest.TestAllTypes.NestedMessage");
+
+ // Prefixes removed.
+ GPBDescriptor *descDesc = [GPBDescriptorProto descriptor];
+ XCTAssertEqualObjects(descDesc.fullName, @"google.protobuf.DescriptorProto");
+ GPBDescriptor *descExtRngDesc = [GPBDescriptorProto_ExtensionRange descriptor];
+ XCTAssertEqualObjects(descExtRngDesc.fullName, @"google.protobuf.DescriptorProto.ExtensionRange");
+
+ // Things that get "_Class" added.
+ GPBDescriptor *pointDesc = [Point_Class descriptor];
+ XCTAssertEqualObjects(pointDesc.fullName, @"protobuf_unittest.Point");
+ GPBDescriptor *pointRectDesc = [Point_Rect descriptor];
+ XCTAssertEqualObjects(pointRectDesc.fullName, @"protobuf_unittest.Point.Rect");
+}
+
- (void)testFieldDescriptor {
GPBDescriptor *descriptor = [TestAllTypes descriptor];