Exemplo n.º 1
0
        public void ExtractByteArrayOptimizedTest(int size)
        {
            byte[] data = Enumerable.Range(0, size).Select(o => (byte)(o % 256)).ToArray();

            Google.Protobuf.ByteString btStr = ProtoBufByteStringHelper.CreateFromByteArrayOptimized(data);
            var extractedArray = ProtoBufByteStringHelper.ExtractByteArrayOptimized(btStr);

            Assert.Equal(data, extractedArray);

            if (ProtoBufByteStringHelper.CanExtractByteArrayOptimized() && ProtoBufByteStringHelper.CanCreateFromByteArrayOptimized() && data.Length >= ProtoBufByteStringHelper.ExtractObjectIndexFromMemoryWithReflectionThreshold)
                Assert.True(object.ReferenceEquals(data, extractedArray));
        }
Exemplo n.º 2
0
 public void AttachBytesIsAvailableTest()
 {
     Assert.True(ProtoBufByteStringHelper.CanCreateFromByteArrayOptimized());
 }