private static void BuffersReferencingSameMemoryAreEqualInEveryAspect(ref ReadOnlyBuffer <byte> buffer, ref ReadOnlyBuffer <byte> pointingToSameMemory) { Assert.True(buffer.Equals(pointingToSameMemory)); Assert.True(pointingToSameMemory.Equals(buffer)); Assert.True(buffer.SequenceEqual(pointingToSameMemory)); Assert.True(pointingToSameMemory.SequenceEqual(buffer)); Assert.True(buffer.SequenceEqual(pointingToSameMemory)); Assert.True(pointingToSameMemory.SequenceEqual(buffer)); }
public void ReadOnlyBuffersOfDifferentValuesAreNotEqual(byte[] bytes, int start, int length) { var differentBytes = bytes.Select(value => ++ value).ToArray(); var buffer = new ReadOnlyBuffer <byte>(bytes, start, length); var ofDifferentValues = new ReadOnlyBuffer <byte>(differentBytes, start, length); Assert.False(buffer.SequenceEqual(ofDifferentValues)); Assert.False(ofDifferentValues.SequenceEqual(buffer)); Assert.False(buffer.SequenceEqual(ofDifferentValues)); Assert.False(ofDifferentValues.SequenceEqual(buffer)); Assert.False(buffer.Equals(ofDifferentValues)); Assert.False(ofDifferentValues.Equals(buffer)); }
public void ReadOnlyBuffersOfEqualValuesInSameOrderAreSequentiallyAndStructurallyEqual(byte[] bytes, int start, int length) { var bytesCopy = bytes.ToArray(); var buffer = new ReadOnlyBuffer <byte>(bytes, start, length); var ofSameValues = new ReadOnlyBuffer <byte>(bytesCopy, start, length); Assert.True(buffer.SequenceEqual(ofSameValues)); Assert.True(ofSameValues.SequenceEqual(buffer)); Assert.True(buffer.SequenceEqual(ofSameValues)); Assert.True(ofSameValues.SequenceEqual(buffer)); Assert.False(buffer.Equals(ofSameValues)); Assert.False(ofSameValues.Equals(buffer)); }