diff --git a/tests/ComputeSharp.NetCore.Tests/BufferTests.cs b/tests/ComputeSharp.NetCore.Tests/BufferTests.cs index 90300354..444778cd 100644 --- a/tests/ComputeSharp.NetCore.Tests/BufferTests.cs +++ b/tests/ComputeSharp.NetCore.Tests/BufferTests.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using ComputeSharp.Graphics.Buffers; using ComputeSharp.NetCore.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -12,8 +13,7 @@ namespace ComputeSharp.NetCore.Tests [TestMethod] public void ReadWriteBufferGetSetData() { - float[] array = new float[4096]; - array.AsSpan().FillRandom(); + float[] array = Enumerable.Range(0, 4096).Select(i => (float)i).ToArray(); using ReadWriteBuffer buffer = Gpu.Default.AllocateReadWriteBuffer(array); float[] result = buffer.GetData(); @@ -24,8 +24,7 @@ namespace ComputeSharp.NetCore.Tests [TestMethod] public void ReadOnlyBufferGetSetData() { - float[] array = new float[4096]; - array.AsSpan().FillRandom(); + float[] array = Enumerable.Range(0, 4096).Select(i => (float)i).ToArray(); using ReadOnlyBuffer buffer = Gpu.Default.AllocateReadOnlyBuffer(array); float[] result = buffer.GetData(); diff --git a/tests/ComputeSharp.NetCore.Tests/Extensions/SpanExtensions.cs b/tests/ComputeSharp.NetCore.Tests/Extensions/SpanExtensions.cs index bb52f8be..11ec9ddf 100644 --- a/tests/ComputeSharp.NetCore.Tests/Extensions/SpanExtensions.cs +++ b/tests/ComputeSharp.NetCore.Tests/Extensions/SpanExtensions.cs @@ -9,21 +9,6 @@ namespace ComputeSharp.NetCore.Tests.Extensions /// public static class SpanExtensions { - /// - /// Fills an input instance with random values - /// - /// The target to fill - public static void FillRandom(this Span span) - { - if (span.Length == 0) return; - - var l = span.Length; - ref var rspan = ref span.GetPinnableReference(); - - for (var i = 0; i < l; i++) - Unsafe.Add(ref rspan, i) = (float)ConcurrentRandom.Instance.NextDouble(); - } - /// /// The maximum threshold to validate two values as being equal /// diff --git a/tests/ComputeSharp.NetCore.Tests/Extensions/Types/ConcurrentRandom.cs b/tests/ComputeSharp.NetCore.Tests/Extensions/Types/ConcurrentRandom.cs deleted file mode 100644 index 5cbd72c0..00000000 --- a/tests/ComputeSharp.NetCore.Tests/Extensions/Types/ConcurrentRandom.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Runtime.CompilerServices; -using System.Threading; - -namespace System -{ - /// - /// A thread-safe wrapper class - /// - public static class ConcurrentRandom - { - // Shared seed - private static int _Seed = Environment.TickCount; - - /// - /// The object that provides the instances - /// - private static readonly ThreadLocal _Instance = new ThreadLocal(() => new Random(Interlocked.Increment(ref _Seed))); - - /// - /// Gets a thread-safe instance - /// - public static Random Instance - { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => _Instance.Value; - } - } -} \ No newline at end of file