From 322bbe00f77772ba6b0e25759de95dd517b6014c Mon Sep 17 00:00:00 2001 From: vnugent Date: Sat, 14 Sep 2024 15:43:45 -0400 Subject: build: Testing updates and easier dev-testing --- lib/Utils/tests/IO/VnMemoryStreamTests.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'lib/Utils/tests/IO') diff --git a/lib/Utils/tests/IO/VnMemoryStreamTests.cs b/lib/Utils/tests/IO/VnMemoryStreamTests.cs index 9bcb823..6bbf328 100644 --- a/lib/Utils/tests/IO/VnMemoryStreamTests.cs +++ b/lib/Utils/tests/IO/VnMemoryStreamTests.cs @@ -47,8 +47,11 @@ namespace VNLib.Utils.IO.Tests Assert.IsTrue(vms.CanWrite == true); } + //Handle should throw since the stream owns the handle and it gets dispoed + Assert.ThrowsException(handle.ThrowIfClosed); + //From existing data - ReadOnlySpan testSpan = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }; + ReadOnlySpan testSpan = [1, 2, 3, 4, 5, 6, 7, 8]; using (VnMemoryStream vms = new (privateHeap, testSpan)) { Assert.IsTrue(vms.Length == testSpan.Length); @@ -125,19 +128,13 @@ namespace VNLib.Utils.IO.Tests ReadOnlyMemory memory = vms.AsMemory(); Assert.AreEqual(memory.Length, testData.Length); - for (int i = 0; i < memory.Length; i++) - { - Assert.AreEqual(memory.Span[i], testData[i]); - } + Assert.IsTrue(memory.Span.SequenceEqual(testData)); //Get the data as a byte array byte[] array = vms.ToArray(); Assert.AreEqual(array.Length, testData.Length); - for (int i = 0; i < array.Length; i++) - { - Assert.AreEqual(array[i], testData[i]); - } + Assert.IsTrue(array.AsSpan().SequenceEqual(testData)); } } } \ No newline at end of file -- cgit