Added test for ByteString.CopyFrom(ReadOnlySpan<byte> bytes)

pull/7701/head
Bas van der Linden 5 years ago
parent ead45182aa
commit 12d7976055
  1. 13
      csharp/src/Google.Protobuf.Test/ByteStringTest.cs

@ -110,6 +110,18 @@ namespace Google.Protobuf
Assert.AreEqual(10, bs[0]);
}
[Test]
public void CopyFromReadOnlySpanCopiesContents()
{
byte[] data = new byte[1];
data[0] = 10;
ReadOnlySpan<byte> byteSpan = data;
var bs = ByteString.CopyFrom(byteSpan);
Assert.AreEqual(10, bs[0]);
data[0] = 5;
Assert.AreEqual(10, bs[0]);
}
[Test]
public void ToByteArrayCopiesContents()
{
@ -249,5 +261,6 @@ namespace Google.Protobuf
var copied = byteString.Memory.ToArray();
CollectionAssert.AreEqual(byteString, copied);
}
}
}
Loading…
Cancel
Save