Example #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));
        }
Example #2
0
 public byte[] ExtractData()
 {
     //return this.Data.ToByteArray();
     return(ProtoBufByteStringHelper.ExtractByteArrayOptimized(this.Data));
 }