From a0eb6427ebdb3e654dbf5ab736dcd5feae926fb5 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 7 Jan 2022 11:50:23 +0100 Subject: [PATCH] Fix unit tests --- tests/ComputeSharp.Tests/ComputeContextTests.cs | 11 ++++------- .../Extensions/GraphicsDeviceExtensions.cs | 13 +++++-------- tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs | 5 +---- tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs | 5 +---- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/tests/ComputeSharp.Tests/ComputeContextTests.cs b/tests/ComputeSharp.Tests/ComputeContextTests.cs index 907818cc..4265c32f 100644 --- a/tests/ComputeSharp.Tests/ComputeContextTests.cs +++ b/tests/ComputeSharp.Tests/ComputeContextTests.cs @@ -1,15 +1,12 @@ using System; using System.Linq; using System.Threading.Tasks; -using ComputeSharp.__Internals; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; using ComputeSharp.Tests.Helpers; using Microsoft.Toolkit.HighPerformance; using Microsoft.VisualStudio.TestTools.UnitTesting; -#pragma warning disable CS0618 - namespace ComputeSharp.Tests; [TestClass] @@ -182,7 +179,7 @@ public partial class ComputeContextTests public void Clear_ReadWriteTexture2D_WithPixel(Device device, Type cpuType, Type gpuType) { static void Test(Device device) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { if (!device.Get().IsReadWriteTexture2DSupportedForType()) @@ -224,7 +221,7 @@ public partial class ComputeContextTests public void Clear_ReadWriteTexture3D_WithPixel(Device device, Type cpuType, Type gpuType) { static void Test(Device device) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { if (!device.Get().IsReadWriteTexture2DSupportedForType()) @@ -266,7 +263,7 @@ public partial class ComputeContextTests public void Clear_ReadWriteTexture2D_WithPixel_AsNormalizedTexture(Device device, Type cpuType, Type gpuType) { static void Test(Device device) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { if (!device.Get().IsReadWriteTexture2DSupportedForType()) @@ -308,7 +305,7 @@ public partial class ComputeContextTests public void Clear_ReadWriteTexture3D_WithPixel_AsNormalizedTexture(Device device, Type cpuType, Type gpuType) { static void Test(Device device) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { if (!device.Get().IsReadWriteTexture2DSupportedForType()) diff --git a/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs b/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs index d143dbee..09d85ec9 100644 --- a/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs +++ b/tests/ComputeSharp.Tests/Extensions/GraphicsDeviceExtensions.cs @@ -1,10 +1,7 @@ using System; using System.IO; -using ComputeSharp.__Internals; using ComputeSharp.Resources; -#pragma warning disable CS0618 - namespace ComputeSharp.Tests.Extensions; /// @@ -66,7 +63,7 @@ public static class GraphicsDeviceExtensions /// The allocation mode to use for the new resource. /// A instance of the requested size. public static Texture2D AllocateTexture2D(this GraphicsDevice device, Type type, int width, int height, AllocationMode allocationMode = AllocationMode.Default) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { return type switch @@ -112,7 +109,7 @@ public static class GraphicsDeviceExtensions /// The allocation mode to use for the new resource. /// A instance of the requested size. public static Texture3D AllocateTexture3D(this GraphicsDevice device, Type type, int width, int height, int depth, AllocationMode allocationMode = AllocationMode.Default) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { return type switch @@ -322,7 +319,7 @@ public static class GraphicsDeviceExtensions /// The filename of the image file to load and decode into the texture. /// A instance with the contents of the specified file. public static Texture2D LoadTexture2D(this GraphicsDevice device, Type textureType, Type inputType, string filename) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { return textureType switch @@ -353,7 +350,7 @@ public static class GraphicsDeviceExtensions /// The buffer with the image data to load and decode into the texture. /// A instance with the contents of the specified buffer. public static Texture2D LoadTexture2D(this GraphicsDevice device, Type type, byte[] buffer) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { return type switch @@ -374,7 +371,7 @@ public static class GraphicsDeviceExtensions /// The stream with the image data to load and decode into the texture. /// A instance with the contents of the specified stream. public static Texture2D LoadTexture2D(this GraphicsDevice device, Type type, Stream stream) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { return type switch diff --git a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs index c4103d96..63a8943f 100644 --- a/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture2DTests.Pixels.cs @@ -2,7 +2,6 @@ using System.IO; using System.Numerics; using System.Reflection; -using ComputeSharp.__Internals; using ComputeSharp.Resources; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; @@ -10,8 +9,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using SixLabors.ImageSharp; using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32; -#pragma warning disable CS0618 - namespace ComputeSharp.Tests; public partial class Texture2DTests @@ -35,7 +32,7 @@ public partial class Texture2DTests public void Allocate_Uninitialized_Pixel_Ok(Device device, Type textureType, Type t, Type tPixel) { static void Test(Device device, Type textureType) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { using Texture2D texture = device.Get().AllocateTexture2D(textureType, 128, 128); diff --git a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs index 4d18fe94..0441ae8e 100644 --- a/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs +++ b/tests/ComputeSharp.Tests/Texture3DTests.Pixels.cs @@ -1,14 +1,11 @@ using System; using System.Numerics; using System.Reflection; -using ComputeSharp.__Internals; using ComputeSharp.Resources; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; -#pragma warning disable CS0618 - namespace ComputeSharp.Tests; public partial class Texture3DTests @@ -32,7 +29,7 @@ public partial class Texture3DTests public void Allocate_Uninitialized_Pixel_Ok(Device device, Type textureType, Type t, Type tPixel) { static void Test(Device device, Type textureType) - where T : unmanaged, IUnorm + where T : unmanaged, IPixel where TPixel : unmanaged { using Texture3D texture = device.Get().AllocateTexture3D(textureType, 128, 128, 2);