From d7599ef181a899d8274405c6d1e3f93bc2168ae7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 24 Aug 2019 23:57:25 +0200 Subject: [PATCH] Added tests for the new intrinsics --- tests/ComputeSharp.Tests/IntrinsicTests.cs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/ComputeSharp.Tests/IntrinsicTests.cs diff --git a/tests/ComputeSharp.Tests/IntrinsicTests.cs b/tests/ComputeSharp.Tests/IntrinsicTests.cs new file mode 100644 index 00000000..6a3bfc0b --- /dev/null +++ b/tests/ComputeSharp.Tests/IntrinsicTests.cs @@ -0,0 +1,32 @@ +using System; +using ComputeSharp.Graphics.Buffers; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace ComputeSharp.Tests +{ + [TestClass] + [TestCategory("IntrinsicTests")] + public class IntrinsicTests + { + [TestMethod] + public void LocalScalarAssignToBuffer() + { + float angle = 80; + using ReadWriteBuffer buffer = Gpu.Default.AllocateReadWriteBuffer(4); + + Action action = id => + { + buffer[0] = Hlsl.Sin(angle); + buffer[1] = Hlsl.Cos(angle); + Hlsl.SinCos(angle, out buffer[2], out buffer[3]); + }; + + Gpu.Default.For(1, action); + + float[] result = buffer.GetData(); + + Assert.IsTrue(MathF.Abs(result[0] - result[2]) < 0.0001f); + Assert.IsTrue(MathF.Abs(result[1] - result[3]) < 0.0001f); + } + } +}