public void Char() { var writer = new FastMemoryWriter(); writer.Write('a'); var result = writer.ToArray(); Assert.True(result[0] == (byte)'a'); }
public void Empty() { var writer = new FastMemoryWriter(); var result = writer.ToArray(); var empty = new byte[0]; Assert.True(empty.SequenceEqual(result)); }
public void Byte() { byte digit = 10; var writer = new FastMemoryWriter(); writer.Write(digit); var result = writer.ToArray(); Assert.True(result.First() == digit); }
public void Bool() { var writer = new FastMemoryWriter(); writer.Write(true); writer.Write(false); var result = writer.ToArray(); Assert.True(result[0] == 1); Assert.True(result[1] == 0); }
public void Bytesv2() { var bytes = new byte[] { 10, 10, 11, 12 }; var writer = new FastMemoryWriter(); writer.Write(bytes, 0, bytes.Length); var result = writer.ToArray(); Assert.True(bytes.SequenceEqual(result)); }
public void Int64() { long digit = 10; var writer = new FastMemoryWriter(); writer.Write(digit); var result = writer.ToArray(); var value = BitConverter.GetBytes(digit); Assert.True(value.SequenceEqual(result)); }
public void String() { var text = "lorem te ipsum"; var writer = new FastMemoryWriter(); writer.Write(text); var result = writer.ToArray(); var bytes = BitConverter.GetBytes(text.Length); bytes = bytes.Concat(Encoding.UTF8.GetBytes(text)).ToArray(); Assert.True(bytes.SequenceEqual(result)); }
public void OnlyFastMemoryWriter() { for (int j = 0; j < 10; j++) { using (var memory = new FastMemoryWriter(this._hugeArrayPool)) { for (int i = 0; i < this.ItemCount; i++) { memory.Write(1.0); } var bytes = memory.ToArray(); } } }
public void AbleToProcess(int size) { var count = 100; var bytes = new byte[size]; using (var writer = new FastMemoryWriter()) { for (int i = 0; i < count; i++) { writer.Write(bytes); } var result = writer.ToArray(); Assert.True(Enumerable.Repeat(bytes, count).SelectMany(o => o).SequenceEqual(result)); } }
public void FastMemoryWriterAndBinaryWriter() { for (int j = 0; j < 10; j++) { using (var memory = new FastMemoryWriter(this._hugeArrayPool)) using (var writer = new BinaryWriter(memory)) { for (int i = 0; i < this.ItemCount; i++) { writer.Write(1.0); } var bytes = memory.ToArray(); } } }
public void FastBytes() { var data = new byte[this.Size]; for (int j = 0; j < 10; j++) { using (var memory = new FastMemoryWriter(this._hugeArrayPool)) { for (int i = 0; i < this.ItemCount; i++) { memory.Write(data, 0, data.Length); } var bytes = memory.ToArray(); } } }