Added a few more tests to ensure XxxxList { get; } clones readonly builder

pull/288/head
csharptest 13 years ago committed by rogerk
parent 7b6044f888
commit 2a1f0bd440
  1. 17
      src/ProtocolBuffers.Test/ReusableBuilderTest.cs

@ -89,6 +89,15 @@ namespace Google.ProtocolBuffers
Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
}
[Test]
public void CloneOnGetRepeatedBoolList()
{
TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
GC.KeepAlive(builder.RepeatedBoolList);
Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
}
[Test]
public void CloneOnChangeMessage()
{
@ -108,11 +117,11 @@ namespace Google.ProtocolBuffers
}
[Test]
public void CloneOnAddRepeatedForeignMessage()
public void CloneOnGetRepeatedForeignMessageList()
{
TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
builder.AddRepeatedForeignMessage(ForeignMessage.DefaultInstance);
GC.KeepAlive(builder.RepeatedForeignMessageList);
Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
}
@ -126,11 +135,11 @@ namespace Google.ProtocolBuffers
}
[Test]
public void CloneOnAddRepeatedForeignEnum()
public void CloneOnGetRepeatedForeignEnumList()
{
TestAllTypes.Builder builder = TestAllTypes.DefaultInstance.ToBuilder();
Assert.IsTrue(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
builder.AddRepeatedForeignEnum(ForeignEnum.FOREIGN_BAR);
GC.KeepAlive(builder.RepeatedForeignEnumList);
Assert.IsFalse(ReferenceEquals(TestAllTypes.DefaultInstance, builder.Build()));
}

Loading…
Cancel
Save