ADD: added new version of protobuf
This commit is contained in:
@@ -34,11 +34,11 @@
|
||||
|
||||
#import "GPBMessage.h"
|
||||
|
||||
#import "objectivec/Tests/MapUnittest.pbobjc.h"
|
||||
#import "objectivec/Tests/Unittest.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestPreserveUnknownEnum.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "objectivec/Tests/UnittestRuntimeProto3.pbobjc.h"
|
||||
#import "google/protobuf/MapUnittest.pbobjc.h"
|
||||
#import "google/protobuf/Unittest.pbobjc.h"
|
||||
#import "google/protobuf/UnittestPreserveUnknownEnum.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto2.pbobjc.h"
|
||||
#import "google/protobuf/UnittestRuntimeProto3.pbobjc.h"
|
||||
|
||||
@interface MessageMergeTests : GPBTestCase
|
||||
@end
|
||||
@@ -197,8 +197,9 @@
|
||||
// Known value.
|
||||
|
||||
src.e = UnknownEnumsMyEnum_Bar;
|
||||
src.repeatedEArray = [GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnum_Bar];
|
||||
src.repeatedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnum_Bar];
|
||||
src.repeatedPackedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:UnknownEnumsMyEnum_Bar];
|
||||
@@ -210,7 +211,8 @@
|
||||
XCTAssertEqual(dst.repeatedEArray.count, 1U);
|
||||
XCTAssertEqual([dst.repeatedEArray valueAtIndex:0], UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual(dst.repeatedPackedEArray.count, 1U);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray valueAtIndex:0], UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray valueAtIndex:0],
|
||||
UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual(dst.oneofE1, UnknownEnumsMyEnum_Bar);
|
||||
|
||||
// Unknown value.
|
||||
@@ -218,8 +220,9 @@
|
||||
const int32_t kUnknownValue = 666;
|
||||
|
||||
SetUnknownEnumsMyMessage_E_RawValue(src, kUnknownValue);
|
||||
src.repeatedEArray = [GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:kUnknownValue];
|
||||
src.repeatedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:kUnknownValue];
|
||||
src.repeatedPackedEArray =
|
||||
[GPBEnumArray arrayWithValidationFunction:UnknownEnumsMyEnum_IsValidValue
|
||||
rawValue:kUnknownValue];
|
||||
@@ -235,11 +238,13 @@
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual([dst.repeatedEArray rawValueAtIndex:1], kUnknownValue);
|
||||
XCTAssertEqual(dst.repeatedPackedEArray.count, 2U);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray valueAtIndex:0], UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray valueAtIndex:0],
|
||||
UnknownEnumsMyEnum_Bar);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray valueAtIndex:1],
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual([dst.repeatedPackedEArray rawValueAtIndex:1], kUnknownValue);
|
||||
XCTAssertEqual(dst.oneofE1, UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(dst.oneofE1,
|
||||
UnknownEnumsMyEnum_GPBUnrecognizedEnumeratorValue);
|
||||
XCTAssertEqual(UnknownEnumsMyMessage_OneofE1_RawValue(dst), kUnknownValue);
|
||||
}
|
||||
|
||||
@@ -253,9 +258,6 @@
|
||||
|
||||
dst.oneofEnum = Message2_Enum_Bar;
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE MERGE2_TEST(SET_NAME, SET_VALUE, CLEARED_NAME, CLEARED_DEFAULT)
|
||||
//% src.oneof##SET_NAME = SET_VALUE;
|
||||
//% [dst mergeFrom:src];
|
||||
@@ -265,6 +267,7 @@
|
||||
//%
|
||||
//%PDDM-EXPAND MERGE2_TEST(Int32, 10, Enum, Message2_Enum_Baz)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofInt32 = 10;
|
||||
[dst mergeFrom:src];
|
||||
@@ -272,8 +275,10 @@
|
||||
XCTAssertEqual(dst.oneofInt32, 10);
|
||||
XCTAssertEqual(dst.oneofEnum, Message2_Enum_Baz);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Int64, 11, Int32, 100)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofInt64 = 11;
|
||||
[dst mergeFrom:src];
|
||||
@@ -281,8 +286,10 @@
|
||||
XCTAssertEqual(dst.oneofInt64, 11);
|
||||
XCTAssertEqual(dst.oneofInt32, 100);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Uint32, 12U, Int64, 101)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofUint32 = 12U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -290,8 +297,10 @@
|
||||
XCTAssertEqual(dst.oneofUint32, 12U);
|
||||
XCTAssertEqual(dst.oneofInt64, 101);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Uint64, 13U, Uint32, 102U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofUint64 = 13U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -299,8 +308,10 @@
|
||||
XCTAssertEqual(dst.oneofUint64, 13U);
|
||||
XCTAssertEqual(dst.oneofUint32, 102U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sint32, 14, Uint64, 103U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSint32 = 14;
|
||||
[dst mergeFrom:src];
|
||||
@@ -308,8 +319,10 @@
|
||||
XCTAssertEqual(dst.oneofSint32, 14);
|
||||
XCTAssertEqual(dst.oneofUint64, 103U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sint64, 15, Sint32, 104)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSint64 = 15;
|
||||
[dst mergeFrom:src];
|
||||
@@ -317,8 +330,10 @@
|
||||
XCTAssertEqual(dst.oneofSint64, 15);
|
||||
XCTAssertEqual(dst.oneofSint32, 104);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Fixed32, 16U, Sint64, 105)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFixed32 = 16U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -326,8 +341,10 @@
|
||||
XCTAssertEqual(dst.oneofFixed32, 16U);
|
||||
XCTAssertEqual(dst.oneofSint64, 105);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Fixed64, 17U, Fixed32, 106U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFixed64 = 17U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -335,8 +352,10 @@
|
||||
XCTAssertEqual(dst.oneofFixed64, 17U);
|
||||
XCTAssertEqual(dst.oneofFixed32, 106U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sfixed32, 18, Fixed64, 107U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSfixed32 = 18;
|
||||
[dst mergeFrom:src];
|
||||
@@ -344,8 +363,10 @@
|
||||
XCTAssertEqual(dst.oneofSfixed32, 18);
|
||||
XCTAssertEqual(dst.oneofFixed64, 107U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Sfixed64, 19, Sfixed32, 108)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSfixed64 = 19;
|
||||
[dst mergeFrom:src];
|
||||
@@ -353,8 +374,10 @@
|
||||
XCTAssertEqual(dst.oneofSfixed64, 19);
|
||||
XCTAssertEqual(dst.oneofSfixed32, 108);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Float, 20.0f, Sfixed64, 109)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFloat = 20.0f;
|
||||
[dst mergeFrom:src];
|
||||
@@ -362,8 +385,10 @@
|
||||
XCTAssertEqual(dst.oneofFloat, 20.0f);
|
||||
XCTAssertEqual(dst.oneofSfixed64, 109);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Double, 21.0, Float, 110.0f)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofDouble = 21.0;
|
||||
[dst mergeFrom:src];
|
||||
@@ -371,8 +396,10 @@
|
||||
XCTAssertEqual(dst.oneofDouble, 21.0);
|
||||
XCTAssertEqual(dst.oneofFloat, 110.0f);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Bool, NO, Double, 111.0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofBool = NO;
|
||||
[dst mergeFrom:src];
|
||||
@@ -380,8 +407,10 @@
|
||||
XCTAssertEqual(dst.oneofBool, NO);
|
||||
XCTAssertEqual(dst.oneofDouble, 111.0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE2_TEST(Enum, Message2_Enum_Bar, Bool, YES)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofEnum = Message2_Enum_Bar;
|
||||
[dst mergeFrom:src];
|
||||
@@ -389,10 +418,9 @@
|
||||
XCTAssertEqual(dst.oneofEnum, Message2_Enum_Bar);
|
||||
XCTAssertEqual(dst.oneofBool, YES);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END (14 expansions)
|
||||
|
||||
// clang-format on
|
||||
|
||||
NSString *oneofStringDefault = @"string";
|
||||
NSData *oneofBytesDefault = [@"data" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
||||
@@ -405,7 +433,8 @@
|
||||
src.oneofBytes = [@"bar" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message2_O_OneOfCase_OneofBytes);
|
||||
XCTAssertEqualObjects(dst.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofBytes,
|
||||
[@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofString, oneofStringDefault);
|
||||
|
||||
Message2_OneofGroup *group = [Message2_OneofGroup message];
|
||||
@@ -477,9 +506,6 @@
|
||||
|
||||
dst.oneofEnum = Message3_Enum_Bar;
|
||||
|
||||
// Disable clang-format for the macros.
|
||||
// clang-format off
|
||||
|
||||
//%PDDM-DEFINE MERGE3_TEST(SET_NAME, SET_VALUE, CLEARED_NAME, CLEARED_DEFAULT)
|
||||
//% src.oneof##SET_NAME = SET_VALUE;
|
||||
//% [dst mergeFrom:src];
|
||||
@@ -489,6 +515,7 @@
|
||||
//%
|
||||
//%PDDM-EXPAND MERGE3_TEST(Int32, 10, Enum, Message3_Enum_Foo)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofInt32 = 10;
|
||||
[dst mergeFrom:src];
|
||||
@@ -496,8 +523,10 @@
|
||||
XCTAssertEqual(dst.oneofInt32, 10);
|
||||
XCTAssertEqual(dst.oneofEnum, Message3_Enum_Foo);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Int64, 11, Int32, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofInt64 = 11;
|
||||
[dst mergeFrom:src];
|
||||
@@ -505,8 +534,10 @@
|
||||
XCTAssertEqual(dst.oneofInt64, 11);
|
||||
XCTAssertEqual(dst.oneofInt32, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Uint32, 12U, Int64, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofUint32 = 12U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -514,8 +545,10 @@
|
||||
XCTAssertEqual(dst.oneofUint32, 12U);
|
||||
XCTAssertEqual(dst.oneofInt64, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Uint64, 13U, Uint32, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofUint64 = 13U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -523,8 +556,10 @@
|
||||
XCTAssertEqual(dst.oneofUint64, 13U);
|
||||
XCTAssertEqual(dst.oneofUint32, 0U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sint32, 14, Uint64, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSint32 = 14;
|
||||
[dst mergeFrom:src];
|
||||
@@ -532,8 +567,10 @@
|
||||
XCTAssertEqual(dst.oneofSint32, 14);
|
||||
XCTAssertEqual(dst.oneofUint64, 0U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sint64, 15, Sint32, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSint64 = 15;
|
||||
[dst mergeFrom:src];
|
||||
@@ -541,8 +578,10 @@
|
||||
XCTAssertEqual(dst.oneofSint64, 15);
|
||||
XCTAssertEqual(dst.oneofSint32, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Fixed32, 16U, Sint64, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFixed32 = 16U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -550,8 +589,10 @@
|
||||
XCTAssertEqual(dst.oneofFixed32, 16U);
|
||||
XCTAssertEqual(dst.oneofSint64, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Fixed64, 17U, Fixed32, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFixed64 = 17U;
|
||||
[dst mergeFrom:src];
|
||||
@@ -559,8 +600,10 @@
|
||||
XCTAssertEqual(dst.oneofFixed64, 17U);
|
||||
XCTAssertEqual(dst.oneofFixed32, 0U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sfixed32, 18, Fixed64, 0U)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSfixed32 = 18;
|
||||
[dst mergeFrom:src];
|
||||
@@ -568,8 +611,10 @@
|
||||
XCTAssertEqual(dst.oneofSfixed32, 18);
|
||||
XCTAssertEqual(dst.oneofFixed64, 0U);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Sfixed64, 19, Sfixed32, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofSfixed64 = 19;
|
||||
[dst mergeFrom:src];
|
||||
@@ -577,8 +622,10 @@
|
||||
XCTAssertEqual(dst.oneofSfixed64, 19);
|
||||
XCTAssertEqual(dst.oneofSfixed32, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Float, 20.0f, Sfixed64, 0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofFloat = 20.0f;
|
||||
[dst mergeFrom:src];
|
||||
@@ -586,8 +633,10 @@
|
||||
XCTAssertEqual(dst.oneofFloat, 20.0f);
|
||||
XCTAssertEqual(dst.oneofSfixed64, 0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Double, 21.0, Float, 0.0f)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofDouble = 21.0;
|
||||
[dst mergeFrom:src];
|
||||
@@ -595,8 +644,10 @@
|
||||
XCTAssertEqual(dst.oneofDouble, 21.0);
|
||||
XCTAssertEqual(dst.oneofFloat, 0.0f);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Bool, YES, Double, 0.0)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofBool = YES;
|
||||
[dst mergeFrom:src];
|
||||
@@ -604,8 +655,10 @@
|
||||
XCTAssertEqual(dst.oneofBool, YES);
|
||||
XCTAssertEqual(dst.oneofDouble, 0.0);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND MERGE3_TEST(Enum, Message3_Enum_Bar, Bool, NO)
|
||||
// This block of code is generated, do not edit it directly.
|
||||
// clang-format off
|
||||
|
||||
src.oneofEnum = Message3_Enum_Bar;
|
||||
[dst mergeFrom:src];
|
||||
@@ -613,10 +666,9 @@
|
||||
XCTAssertEqual(dst.oneofEnum, Message3_Enum_Bar);
|
||||
XCTAssertEqual(dst.oneofBool, NO);
|
||||
|
||||
// clang-format on
|
||||
//%PDDM-EXPAND-END (14 expansions)
|
||||
|
||||
// clang-format on
|
||||
|
||||
NSString *oneofStringDefault = @"";
|
||||
NSData *oneofBytesDefault = [NSData data];
|
||||
|
||||
@@ -629,9 +681,11 @@
|
||||
src.oneofBytes = [@"bar" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[dst mergeFrom:src];
|
||||
XCTAssertEqual(dst.oOneOfCase, Message3_O_OneOfCase_OneofBytes);
|
||||
XCTAssertEqualObjects(dst.oneofBytes, [@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofBytes,
|
||||
[@"bar" dataUsingEncoding:NSUTF8StringEncoding]);
|
||||
XCTAssertEqualObjects(dst.oneofString, oneofStringDefault);
|
||||
|
||||
|
||||
Message3 *subMessage = [Message3 message];
|
||||
subMessage.optionalInt32 = 777;
|
||||
src.oneofMessage = subMessage;
|
||||
|
||||
Reference in New Issue
Block a user