ScopeMipMathTests.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using PerformanceScope.Core;
  2. using Xunit;
  3. namespace PerformanceScope.Tests
  4. {
  5. public class ScopeMipMathTests
  6. {
  7. [Fact]
  8. public void 游戏默认模式_不覆盖()
  9. {
  10. Assert.False(ScopeMipMath.TryResolve(ScopeSettingMode.GameDefault, 5f, out float bias));
  11. Assert.Equal(0f, bias);
  12. }
  13. [Theory]
  14. [InlineData(0f, 0f)]
  15. [InlineData(3f, 3f)]
  16. [InlineData(-1.5f, -1.5f)]
  17. public void 自定义模式_返回夹取后的值(float input, float expected)
  18. {
  19. Assert.True(ScopeMipMath.TryResolve(ScopeSettingMode.Custom, input, out float bias));
  20. Assert.Equal(expected, bias, 3);
  21. }
  22. [Theory]
  23. [InlineData(99f, ScopeMipMath.MaxBias)]
  24. [InlineData(-99f, ScopeMipMath.MinBias)]
  25. public void 自定义模式_越界被夹取(float input, float expected)
  26. {
  27. Assert.True(ScopeMipMath.TryResolve(ScopeSettingMode.Custom, input, out float bias));
  28. Assert.Equal(expected, bias, 3);
  29. }
  30. [Theory]
  31. [InlineData(float.NaN)]
  32. [InlineData(float.PositiveInfinity)]
  33. [InlineData(float.NegativeInfinity)]
  34. public void 非法值_回退默认偏差(float input)
  35. {
  36. Assert.Equal(ScopeMipMath.DefaultCustomBias, ScopeMipMath.ClampBias(input), 3);
  37. }
  38. [Fact]
  39. public void 默认自定义偏差在合法区间内()
  40. {
  41. Assert.InRange(ScopeMipMath.DefaultCustomBias, ScopeMipMath.MinBias, ScopeMipMath.MaxBias);
  42. }
  43. }
  44. }