示例#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));
        }
示例#2
0
 public void CanPerformByteArrayExtractionTest()
 {
     Assert.True(ProtoBufByteStringHelper.CanExtractByteArrayOptimized());
 }