Added tests for custom delegates and inline functions

このコミットが含まれているのは:
Sergio Pedri committed 2019-09-05 17:10:47 +02:00
1 親 d4e3e20048
コミット 078c2be9cc
1ファイル変更
+32
+32
ファイルの表示
@@ -75,5 +75,37 @@ namespace ComputeSharp.Tests
Assert.IsTrue(MathF.Abs(result[0] - expected) < 0.0001f);
}
public delegate float Squarer(float x);
[TestMethod]
public void CustomStaticDelegate()
{
using ReadWriteBuffer<float> buffer = Gpu.Default.AllocateReadWriteBuffer<float>(1);
Squarer square = StaticMethodsContainer.Square;
Gpu.Default.For(1, id => buffer[0] = square(3));
float[] result = buffer.GetData();
Assert.IsTrue(MathF.Abs(result[0] - 9) < 0.0001f);
}
[TestMethod]
public void InlineStatelessDelegate()
{
using ReadWriteBuffer<float> buffer = Gpu.Default.AllocateReadWriteBuffer<float>(1);
Func<float, float> f = x => x * x;
Func<int, float> invert = x => -x;
Gpu.Default.For(1, id => buffer[0] = f(3) + invert(8));
float[] result = buffer.GetData();
Assert.IsTrue(MathF.Abs(result[0] - 1) < 0.0001f);
}
}
}