add test for clone of non-empty message (#9193)
* add test for clone * use var * reorder
This commit is contained in:
parent
3be46483ba
commit
867436c0b8
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user