From 1bf4b38f29d6cc3f24ad1e0b6c3339420bd719be Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 8 Mar 2016 09:29:49 -0500 Subject: Fix up handing of fields with leading names that should be all caps. Add a compile test to confirm things are working as expected. --- objectivec/Tests/GPBMessageTests.m | 18 ++++++++++++++++++ objectivec/Tests/unittest_objc.proto | 12 ++++++++++++ 2 files changed, 30 insertions(+) (limited to 'objectivec') diff --git a/objectivec/Tests/GPBMessageTests.m b/objectivec/Tests/GPBMessageTests.m index 7b37ca95..43546156 100644 --- a/objectivec/Tests/GPBMessageTests.m +++ b/objectivec/Tests/GPBMessageTests.m @@ -1820,6 +1820,24 @@ XCTAssertEqualObjects(enumDescriptor, expectedDescriptor); } +- (void)testPropertyNaming { + // objectivec_helpers.cc has some special handing to get proper all caps + // for a few cases to meet objc developer expectations. + // + // This "test" confirms that the expected names are generated, otherwise the + // test itself will fail to compile. + ObjCPropertyNaming *msg = [ObjCPropertyNaming message]; + // On their own, at the end, in the middle. + msg.URL = @"good"; + msg.thumbnailURL = @"good"; + msg.URLFoo = @"good"; + msg.someURLBlah = @"good"; + msg.HTTP = @"good"; + msg.HTTPS = @"good"; + // No caps since it was "urls". + [msg.urlsArray addObject:@"good"]; +} + - (void)testEnumNaming { // objectivec_helpers.cc has some interesting cases to deal with in // EnumValueName/EnumValueShortName. Confirm that things generated as diff --git a/objectivec/Tests/unittest_objc.proto b/objectivec/Tests/unittest_objc.proto index 3bb92761..9483cb1d 100644 --- a/objectivec/Tests/unittest_objc.proto +++ b/objectivec/Tests/unittest_objc.proto @@ -112,6 +112,18 @@ enum retain { serializedSize = 6; } +message ObjCPropertyNaming { + // Test that the properties properly get things all caps. + optional string url = 1; + optional string thumbnail_url = 2; + optional string url_foo = 3; + optional string some_url_blah = 4; + optional string http = 5; + optional string https = 6; + // This one doesn't. + repeated string urls = 7; +} + // EnumValueShortName: The short names shouldn't get suffixes/prefixes. enum Foo { SERIALIZED_SIZE = 1; -- cgit v1.2.3