|
|
|
@ -138,6 +138,29 @@ namespace Google.Protobuf |
|
|
|
|
Assert.AreEqual(message.ToByteArray(), otherEmptyMessage.ToByteArray()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
public void TestClone_LengthDelimited() |
|
|
|
|
{ |
|
|
|
|
var unknownVarintField = new UnknownField(); |
|
|
|
|
unknownVarintField.AddVarint(99); |
|
|
|
|
|
|
|
|
|
var unknownLengthDelimitedField1 = new UnknownField(); |
|
|
|
|
unknownLengthDelimitedField1.AddLengthDelimited(ByteString.CopyFromUtf8("some data")); |
|
|
|
|
|
|
|
|
|
var unknownLengthDelimitedField2 = new UnknownField(); |
|
|
|
|
unknownLengthDelimitedField2.AddLengthDelimited(ByteString.CopyFromUtf8("some more data")); |
|
|
|
|
|
|
|
|
|
var destUnknownFieldSet = new UnknownFieldSet(); |
|
|
|
|
destUnknownFieldSet.AddOrReplaceField(997, unknownVarintField); |
|
|
|
|
destUnknownFieldSet.AddOrReplaceField(999, unknownLengthDelimitedField1); |
|
|
|
|
destUnknownFieldSet.AddOrReplaceField(999, unknownLengthDelimitedField2); |
|
|
|
|
|
|
|
|
|
var clone = UnknownFieldSet.Clone(destUnknownFieldSet); |
|
|
|
|
|
|
|
|
|
Assert.IsTrue(clone.HasField(997)); |
|
|
|
|
Assert.IsTrue(clone.HasField(999)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
[TestCaseSource(typeof(Data), "Messages")] |
|
|
|
|
public void TestDiscardUnknownFields(IMessage message) |
|
|
|
|