diff --git a/.gitignore b/.gitignore index a296142349..8ea85af04a 100644 --- a/.gitignore +++ b/.gitignore @@ -92,7 +92,8 @@ objectivec/ProtocolBuffers_OSX.xcodeproj/xcuserdata/ objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcuserdata/ objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/ProtocolBuffers_iOS.xccheckout objectivec/ProtocolBuffers_iOS.xcodeproj/xcuserdata/ -objectivec/**/.DS_Store +# OS X's Finder creates these for state about opened windows/etc. +**/.DS_Store # Comformance test output conformance/.libs/ diff --git a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj index 38100fae0a..f18ba2f8dc 100644 --- a/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj @@ -725,7 +725,7 @@ INFOPLIST_FILE = "Tests/UnitTests-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_NAME = UnitTests; - SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/Tests/UnitTests-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; }; name = Debug; @@ -742,7 +742,7 @@ INFOPLIST_FILE = "Tests/UnitTests-Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_NAME = UnitTests; - SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/Tests/UnitTests-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h"; }; name = Release; }; diff --git a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj index 0773acb1c7..d6e621e60f 100644 --- a/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj +++ b/objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj @@ -875,7 +875,7 @@ "\"$(DEVELOPER_DIR)/usr/lib\"", ); PRODUCT_NAME = UnitTests; - SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/Tests/UnitTests-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness"; @@ -903,7 +903,7 @@ "\"$(DEVELOPER_DIR)/usr/lib\"", ); PRODUCT_NAME = UnitTests; - SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/Tests/UnitTests-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Tests/UnitTests-Bridging-Header.h"; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/iOSTestHarness.app/iOSTestHarness"; }; diff --git a/objectivec/Tests/GPBMessageTests+Serialization.m b/objectivec/Tests/GPBMessageTests+Serialization.m index 0859f14c08..6d5527b503 100644 --- a/objectivec/Tests/GPBMessageTests+Serialization.m +++ b/objectivec/Tests/GPBMessageTests+Serialization.m @@ -146,9 +146,6 @@ static NSData *DataFromCStr(const char *str) { orig.repeatedEnumArray = [GPBEnumArray arrayWithValidationFunction:Message3_Enum_IsValidValue rawValue:Message3_Enum_Extra3]; - orig.repeatedPackedEnumArray = - [GPBEnumArray arrayWithValidationFunction:Message3_Enum_IsValidValue - rawValue:Message3_Enum_Extra3]; orig.oneofEnum = Message3_Enum_Extra3; Message2 *msg = [[Message2 alloc] initWithData:[orig data] error:NULL]; @@ -157,19 +154,16 @@ static NSData *DataFromCStr(const char *str) { XCTAssertFalse(msg.hasOptionalEnum); XCTAssertEqual(msg.repeatedEnumArray.count, 0U); - XCTAssertEqual(msg.repeatedPackedEnumArray.count, 0U); XCTAssertEqual(msg.oOneOfCase, Message3_O_OneOfCase_GPBUnsetOneOfCase); // All the values should be in unknown fields. GPBUnknownFieldSet *unknownFields = msg.unknownFields; - XCTAssertEqual([unknownFields countOfFields], 4U); + XCTAssertEqual([unknownFields countOfFields], 3U); XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OptionalEnum]); XCTAssertTrue( [unknownFields hasField:Message2_FieldNumber_RepeatedEnumArray]); - XCTAssertTrue( - [unknownFields hasField:Message2_FieldNumber_RepeatedPackedEnumArray]); XCTAssertTrue([unknownFields hasField:Message2_FieldNumber_OneofEnum]); GPBField *field = [unknownFields getField:Message2_FieldNumber_OptionalEnum]; @@ -177,22 +171,12 @@ static NSData *DataFromCStr(const char *str) { XCTAssertEqual([field.varintList valueAtIndex:0], (uint64_t)Message3_Enum_Extra3); - // TODO(teboring): This test could fail without explicitly marking the repeated_enum in Message3 - // to be unpacked. This is becaucse proto3 repeated primitive field is packed by default. However, - // the proto2 primitive repeated field is still unpacked by default. Previously, parsing of the - // repeated_enum field would fail. To fix it: - // 1) Objective-C implementation of parsing should be able to parse packed field for unpacked - // field and vice versa. - // 2) repeated_packed_enum in Message3 should be removed, because it's unnecessary now. + // Repeated in proto3 default to packed, so this will be length delimited + // unknown field, and the value (Message3_Enum_Extra3) encodes into one byte. field = [unknownFields getField:Message2_FieldNumber_RepeatedEnumArray]; - XCTAssertEqual(field.varintList.count, 1U); - XCTAssertEqual([field.varintList valueAtIndex:0], - (uint64_t)Message3_Enum_Extra3); - - field = [unknownFields getField:Message2_FieldNumber_RepeatedPackedEnumArray]; - XCTAssertEqual(field.varintList.count, 1U); - XCTAssertEqual([field.varintList valueAtIndex:0], - (uint64_t)Message3_Enum_Extra3); + XCTAssertEqual(field.lengthDelimitedList.count, 1U); + NSData *expected = DataFromCStr("\x1E"); + XCTAssertEqualObjects([field.lengthDelimitedList objectAtIndex:0], expected); field = [unknownFields getField:Message2_FieldNumber_OneofEnum]; XCTAssertEqual(field.varintList.count, 1U); diff --git a/objectivec/Tests/unittest_runtime_proto2.proto b/objectivec/Tests/unittest_runtime_proto2.proto index 12a2da68b4..ed835020af 100644 --- a/objectivec/Tests/unittest_runtime_proto2.proto +++ b/objectivec/Tests/unittest_runtime_proto2.proto @@ -78,9 +78,8 @@ message Message2 { repeated group RepeatedGroup = 46 { optional int32 a = 47; } - repeated Message2 repeated_message = 48; - repeated Enum repeated_enum = 49; - repeated Enum repeated_packed_enum = 50 [packed=true]; + repeated Message2 repeated_message = 48; + repeated Enum repeated_enum = 49; oneof o { int32 oneof_int32 = 51 [default = 100]; diff --git a/objectivec/Tests/unittest_runtime_proto3.proto b/objectivec/Tests/unittest_runtime_proto3.proto index a081fa7e39..ad2e3620d3 100644 --- a/objectivec/Tests/unittest_runtime_proto3.proto +++ b/objectivec/Tests/unittest_runtime_proto3.proto @@ -75,11 +75,7 @@ message Message3 { repeated bytes repeated_bytes = 45; // No 'group' in proto3. repeated Message3 repeated_message = 48; - // TODO(teboring): In proto3, repeated primitive field is packed by default. - // testProto2UnknownEnumToUnknownField needs repeated_enum to be unpacked. - // Remove this option when testProto2UnknownEnumToUnknownField. - repeated Enum repeated_enum = 49 [packed=false]; - repeated Enum repeated_packed_enum = 50 [packed=true]; + repeated Enum repeated_enum = 49; oneof o { int32 oneof_int32 = 51;