private void PerformMutationOp_Write() { int len = _rng.Next(300); Span <byte> buf = stackalloc byte[len]; _rng.NextBytes(buf); _strmA.Write(buf); _strmB.Write(buf); Debug.WriteLine($"Write count={len}"); }
private void PerformMutationOp_Write() { int buffLen = _rng.Next(1000) + 1; int offset = _rng.Next(buffLen); int count = _rng.Next(buffLen - offset); byte[] tmp = new byte[count]; _rng.NextBytes(tmp); byte[] buff = new byte[buffLen]; Array.Copy(tmp, 0, buff, offset, count); _strmA.Write(buff, offset, count); _strmB.Write(buff, offset, count); Debug.WriteLine(string.Format("Write offset={0}, count={1}", offset, count)); }
public void WriteZeroBytes() { byte[] buf = Array.Empty<byte>(); MemoryBlockStream ms = new MemoryBlockStream(); ms.Write(buf, 0, 0); Assert.Equal(0, ms.Length); IRandomSource rng = RandomDefaults.CreateRandomSource(1234567); byte[] buf2 = new byte[100]; rng.NextBytes(buf2); ms.Write(buf2); Assert.Equal(ms.ToArray(), buf2); ms.Write(buf, 0, 0); Assert.Equal(ms.Length, buf2.Length); }
public void TestWriteZeroBytes() { byte[] buf = new byte[0]; MemoryBlockStream ms = new MemoryBlockStream(); ms.Write(buf, 0, 0); Assert.AreEqual(ms.Length, 0); IRandomSource rng = RandomDefaults.CreateRandomSource(1234567); byte[] buf2 = new byte[100]; rng.NextBytes(buf2); ms.Write(buf2, 0, buf2.Length); if (!Utils.AreEqual(ms.ToArray(), buf2)) { Assert.Fail(); } ms.Write(buf, 0, 0); Assert.AreEqual(ms.Length, buf2.Length); }