mirror of https://github.com/SixLabors/ImageSharp
15 changed files with 0 additions and 655 deletions
@ -1,234 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
// tell this file to enable debug conditional method calls, i.e. all the debug guard calls
|
|||
#define DEBUG
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.Helpers.Tests |
|||
{ |
|||
public class DebugGuardTests |
|||
{ |
|||
private class Foo |
|||
{ |
|||
} |
|||
|
|||
[Fact] |
|||
public void AllStaticMethodsOnOnDebugGuardHaveDEBUGConditional() |
|||
{ |
|||
IEnumerable<MethodInfo> methods = typeof(DebugGuard).GetTypeInfo().GetMethods() |
|||
.Where(x => x.IsStatic); |
|||
|
|||
foreach (MethodInfo m in methods) |
|||
{ |
|||
IEnumerable<ConditionalAttribute> attribs = m.GetCustomAttributes<ConditionalAttribute>(); |
|||
Assert.True(attribs.Select(x => x.ConditionString).Contains("DEBUG"), $"Method '{m.Name}' does not have [Conditional(\"DEBUG\")] set."); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void NotNull_WhenNull_Throws() |
|||
{ |
|||
Foo foo = null; |
|||
Assert.Throws<ArgumentNullException>(() => Guard.NotNull(foo, nameof(foo))); |
|||
} |
|||
|
|||
[Fact] |
|||
public void NotNull_WhenNotNull() |
|||
{ |
|||
var foo = new Foo(); |
|||
Guard.NotNull(foo, nameof(foo)); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(null, true)] |
|||
[InlineData("", true)] |
|||
[InlineData(" ", true)] |
|||
[InlineData("$", false)] |
|||
[InlineData("lol", false)] |
|||
public void NotNullOrWhiteSpace(string str, bool shouldThrow) |
|||
{ |
|||
if (shouldThrow) |
|||
{ |
|||
Assert.ThrowsAny<ArgumentException>(() => Guard.NotNullOrWhiteSpace(str, nameof(str))); |
|||
} |
|||
else |
|||
{ |
|||
Guard.NotNullOrWhiteSpace(str, nameof(str)); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(true)] |
|||
[InlineData(false)] |
|||
public void IsTrue(bool value) |
|||
{ |
|||
if (!value) |
|||
{ |
|||
Assert.Throws<ArgumentException>(() => Guard.IsTrue(value, nameof(value), "Boo!")); |
|||
} |
|||
else |
|||
{ |
|||
Guard.IsTrue(value, nameof(value), "Boo."); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(true)] |
|||
[InlineData(false)] |
|||
public void IsFalse(bool value) |
|||
{ |
|||
if (value) |
|||
{ |
|||
Assert.Throws<ArgumentException>(() => Guard.IsFalse(value, nameof(value), "Boo!")); |
|||
} |
|||
else |
|||
{ |
|||
Guard.IsFalse(value, nameof(value), "Boo."); |
|||
} |
|||
} |
|||
|
|||
public static readonly TheoryData<int, int, bool> SizeCheckData = new TheoryData<int, int, bool> |
|||
{ |
|||
{ 0, 0, false }, |
|||
{ 1, 1, false }, |
|||
{ 1, 0, false }, |
|||
{ 13, 13, false }, |
|||
{ 20, 13, false }, |
|||
{ 12, 13, true }, |
|||
{ 0, 1, true }, |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(SizeCheckData))] |
|||
public void MustBeSizedAtLeast(int length, int minLength, bool shouldThrow) |
|||
{ |
|||
int[] data = new int[length]; |
|||
|
|||
if (shouldThrow) |
|||
{ |
|||
Assert.Throws<ArgumentException>(() => Guard.MustBeSizedAtLeast((Span<int>)data, minLength, nameof(data))); |
|||
Assert.Throws<ArgumentException>(() => Guard.MustBeSizedAtLeast((ReadOnlySpan<int>)data, minLength, nameof(data))); |
|||
} |
|||
else |
|||
{ |
|||
Guard.MustBeSizedAtLeast((Span<int>)data, minLength, nameof(data)); |
|||
Guard.MustBeSizedAtLeast((ReadOnlySpan<int>)data, minLength, nameof(data)); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(SizeCheckData))] |
|||
public void DestinationShouldNotBeTooShort(int destLength, int sourceLength, bool shouldThrow) |
|||
{ |
|||
int[] dest = new int[destLength]; |
|||
int[] source = new int[sourceLength]; |
|||
|
|||
if (shouldThrow) |
|||
{ |
|||
Assert.Throws<ArgumentException>(() => Guard.DestinationShouldNotBeTooShort((Span<int>)source, (Span<int>)dest, nameof(dest))); |
|||
Assert.Throws<ArgumentException>(() => Guard.DestinationShouldNotBeTooShort((ReadOnlySpan<int>)source, (Span<int>)dest, nameof(dest))); |
|||
} |
|||
else |
|||
{ |
|||
Guard.DestinationShouldNotBeTooShort((Span<int>)source, (Span<int>)dest, nameof(dest)); |
|||
Guard.DestinationShouldNotBeTooShort((ReadOnlySpan<int>)source, (Span<int>)dest, nameof(dest)); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeLessThan_IsLess_ThrowsNoException() |
|||
{ |
|||
DebugGuard.MustBeLessThan(0, 1, "myParamName"); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(2, 1)] |
|||
[InlineData(1, 1)] |
|||
public void MustBeLessThan_IsGreaterOrEqual_ThrowsNoException(int value, int max) |
|||
{ |
|||
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>( |
|||
() => DebugGuard.MustBeLessThan(value, max, "myParamName")); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"Value {value} must be less than {max}.", exception.Message); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 1)] |
|||
[InlineData(1, 1)] |
|||
public void MustBeLessThanOrEqualTo_IsLessOrEqual_ThrowsNoException(int value, int max) |
|||
{ |
|||
DebugGuard.MustBeLessThanOrEqualTo(value, max, "myParamName"); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeLessThanOrEqualTo_IsGreater_ThrowsNoException() |
|||
{ |
|||
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() => DebugGuard.MustBeLessThanOrEqualTo(2, 1, "myParamName")); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"Value 2 must be less than or equal to 1.", exception.Message); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeGreaterThan_IsGreater_ThrowsNoException() |
|||
{ |
|||
DebugGuard.MustBeGreaterThan(2, 1, "myParamName"); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(1, 2)] |
|||
[InlineData(1, 1)] |
|||
public void MustBeGreaterThan_IsLessOrEqual_ThrowsNoException(int value, int min) |
|||
{ |
|||
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>( |
|||
() => DebugGuard.MustBeGreaterThan(value, min, "myParamName")); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"Value {value} must be greater than {min}.", exception.Message); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(2, 1)] |
|||
[InlineData(1, 1)] |
|||
public void MustBeGreaterThanOrEqualTo_IsGreaterOrEqual_ThrowsNoException(int value, int min) |
|||
{ |
|||
DebugGuard.MustBeGreaterThanOrEqualTo(value, min, "myParamName"); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeGreaterThanOrEqualTo_IsLess_ThrowsNoException() |
|||
{ |
|||
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>( |
|||
() => DebugGuard.MustBeGreaterThanOrEqualTo(1, 2, "myParamName")); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"Value 1 must be greater than or equal to 2.", exception.Message); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(new int[] { 1, 2 }, 1)] |
|||
[InlineData(new int[] { 1, 2 }, 2)] |
|||
public void MustBeSizedAtLeast_Array_LengthIsGreaterOrEqual_ThrowsNoException(int[] value, int minLength) |
|||
{ |
|||
DebugGuard.MustBeSizedAtLeast<int>(value, minLength, "myParamName"); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeSizedAtLeast_Array_LengthIsLess_ThrowsException() |
|||
{ |
|||
ArgumentException exception = Assert.Throws<ArgumentException>( |
|||
() => DebugGuard.MustBeSizedAtLeast<int>(new int[] { 1, 2 }, 3, "myParamName")); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"The size must be at least 3.", exception.Message); |
|||
} |
|||
} |
|||
} |
|||
@ -1,59 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Numerics; |
|||
|
|||
namespace SixLabors.Tests.Helpers |
|||
{ |
|||
/// <summary>
|
|||
/// Allows the comparison of single-precision floating point values by precision.
|
|||
/// </summary>
|
|||
public struct FloatRoundingComparer : IEqualityComparer<float>, IEqualityComparer<Vector4> |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="FloatRoundingComparer"/> struct.
|
|||
/// </summary>
|
|||
/// <param name="precision">The number of decimal places (valid values: 0-7).</param>
|
|||
public FloatRoundingComparer(int precision) |
|||
{ |
|||
Guard.MustBeBetweenOrEqualTo(precision, 0, 7, nameof(precision)); |
|||
this.Precision = precision; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the number of decimal places (valid values: 0-7).
|
|||
/// </summary>
|
|||
public int Precision { get; } |
|||
|
|||
/// <inheritdoc />
|
|||
public bool Equals(float x, float y) |
|||
{ |
|||
float xp = (float)Math.Round(x, this.Precision, MidpointRounding.AwayFromZero); |
|||
float yp = (float)Math.Round(y, this.Precision, MidpointRounding.AwayFromZero); |
|||
|
|||
return Comparer<float>.Default.Compare(xp, yp) == 0; |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public bool Equals(Vector4 x, Vector4 y) |
|||
{ |
|||
return this.Equals(x.X, y.X) && this.Equals(x.Y, y.Y) && this.Equals(x.Z, y.Z) && this.Equals(x.W, y.W); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public int GetHashCode(float obj) |
|||
{ |
|||
unchecked |
|||
{ |
|||
int hashCode = obj.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.Precision.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
public int GetHashCode(Vector4 obj) => HashCode.Combine(obj, this.Precision); |
|||
} |
|||
} |
|||
@ -1,19 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.Tests.Helpers |
|||
{ |
|||
public class GeometryUtilitiesTests |
|||
{ |
|||
[Fact] |
|||
public void Convert_Degree_To_Radian() |
|||
=> Assert.Equal((float)(Math.PI / 2D), GeometryUtilities.DegreeToRadian(90F), new FloatRoundingComparer(6)); |
|||
|
|||
[Fact] |
|||
public void Convert_Radian_To_Degree() |
|||
=> Assert.Equal(60F, GeometryUtilities.RadianToDegree((float)(Math.PI / 3D)), new FloatRoundingComparer(5)); |
|||
} |
|||
} |
|||
@ -1,248 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.Helpers.Tests |
|||
{ |
|||
public class GuardTests |
|||
{ |
|||
private class Foo |
|||
{ |
|||
} |
|||
|
|||
[Fact] |
|||
public void NotNull_WhenNull_Throws() |
|||
{ |
|||
Foo foo = null; |
|||
Assert.Throws<ArgumentNullException>(() => Guard.NotNull(foo, nameof(foo))); |
|||
} |
|||
|
|||
[Fact] |
|||
public void NotNull_WhenNotNull() |
|||
{ |
|||
Foo foo = new Foo(); |
|||
Guard.NotNull(foo, nameof(foo)); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(null, true)] |
|||
[InlineData("", true)] |
|||
[InlineData(" ", true)] |
|||
[InlineData("$", false)] |
|||
[InlineData("lol", false)] |
|||
public void NotNullOrWhiteSpace(string str, bool shouldThrow) |
|||
{ |
|||
if (shouldThrow) |
|||
{ |
|||
Assert.ThrowsAny<ArgumentException>(() => Guard.NotNullOrWhiteSpace(str, nameof(str))); |
|||
} |
|||
else |
|||
{ |
|||
Guard.NotNullOrWhiteSpace(str, nameof(str)); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(true)] |
|||
[InlineData(false)] |
|||
public void IsTrue(bool value) |
|||
{ |
|||
if (!value) |
|||
{ |
|||
Assert.Throws<ArgumentException>(() => Guard.IsTrue(value, nameof(value), "Boo!")); |
|||
} |
|||
else |
|||
{ |
|||
Guard.IsTrue(value, nameof(value), "Boo."); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(true)] |
|||
[InlineData(false)] |
|||
public void IsFalse(bool value) |
|||
{ |
|||
if (value) |
|||
{ |
|||
Assert.Throws<ArgumentException>(() => Guard.IsFalse(value, nameof(value), "Boo!")); |
|||
} |
|||
else |
|||
{ |
|||
Guard.IsFalse(value, nameof(value), "Boo."); |
|||
} |
|||
} |
|||
|
|||
public static readonly TheoryData<int, int, bool> SizeCheckData = new TheoryData<int, int, bool> |
|||
{ |
|||
{ 0, 0, false }, |
|||
{ 1, 1, false }, |
|||
{ 1, 0, false }, |
|||
{ 13, 13, false }, |
|||
{ 20, 13, false }, |
|||
{ 12, 13, true }, |
|||
{ 0, 1, true }, |
|||
}; |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(SizeCheckData))] |
|||
public void MustBeSizedAtLeast(int length, int minLength, bool shouldThrow) |
|||
{ |
|||
int[] data = new int[length]; |
|||
|
|||
if (shouldThrow) |
|||
{ |
|||
Assert.Throws<ArgumentException>(() => Guard.MustBeSizedAtLeast((Span<int>)data, minLength, nameof(data))); |
|||
Assert.Throws<ArgumentException>(() => Guard.MustBeSizedAtLeast((ReadOnlySpan<int>)data, minLength, nameof(data))); |
|||
} |
|||
else |
|||
{ |
|||
Guard.MustBeSizedAtLeast((Span<int>)data, minLength, nameof(data)); |
|||
Guard.MustBeSizedAtLeast((ReadOnlySpan<int>)data, minLength, nameof(data)); |
|||
} |
|||
} |
|||
|
|||
[Theory] |
|||
[MemberData(nameof(SizeCheckData))] |
|||
public void DestinationShouldNotBeTooShort(int destLength, int sourceLength, bool shouldThrow) |
|||
{ |
|||
int[] dest = new int[destLength]; |
|||
int[] source = new int[sourceLength]; |
|||
|
|||
if (shouldThrow) |
|||
{ |
|||
Assert.Throws<ArgumentException>(() => Guard.DestinationShouldNotBeTooShort((Span<int>)source, (Span<int>)dest, nameof(dest))); |
|||
Assert.Throws<ArgumentException>(() => Guard.DestinationShouldNotBeTooShort((ReadOnlySpan<int>)source, (Span<int>)dest, nameof(dest))); |
|||
} |
|||
else |
|||
{ |
|||
Guard.DestinationShouldNotBeTooShort((Span<int>)source, (Span<int>)dest, nameof(dest)); |
|||
Guard.DestinationShouldNotBeTooShort((ReadOnlySpan<int>)source, (Span<int>)dest, nameof(dest)); |
|||
} |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeLessThan_IsLess_ThrowsNoException() |
|||
{ |
|||
Guard.MustBeLessThan(0, 1, "myParamName"); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(2, 1)] |
|||
[InlineData(1, 1)] |
|||
public void MustBeLessThan_IsGreaterOrEqual_ThrowsNoException(int value, int max) |
|||
{ |
|||
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() => |
|||
{ |
|||
Guard.MustBeLessThan(value, max, "myParamName"); |
|||
}); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"Value {value} must be less than {max}.", exception.Message); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 1)] |
|||
[InlineData(1, 1)] |
|||
public void MustBeLessThanOrEqualTo_IsLessOrEqual_ThrowsNoException(int value, int max) |
|||
{ |
|||
Guard.MustBeLessThanOrEqualTo(value, max, "myParamName"); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeLessThanOrEqualTo_IsGreater_ThrowsNoException() |
|||
{ |
|||
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() => |
|||
{ |
|||
Guard.MustBeLessThanOrEqualTo(2, 1, "myParamName"); |
|||
}); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"Value 2 must be less than or equal to 1.", exception.Message); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeGreaterThan_IsGreater_ThrowsNoException() |
|||
{ |
|||
Guard.MustBeGreaterThan(2, 1, "myParamName"); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(1, 2)] |
|||
[InlineData(1, 1)] |
|||
public void MustBeGreaterThan_IsLessOrEqual_ThrowsNoException(int value, int min) |
|||
{ |
|||
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() => |
|||
{ |
|||
Guard.MustBeGreaterThan(value, min, "myParamName"); |
|||
}); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"Value {value} must be greater than {min}.", exception.Message); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(2, 1)] |
|||
[InlineData(1, 1)] |
|||
public void MustBeGreaterThanOrEqualTo_IsGreaterOrEqual_ThrowsNoException(int value, int min) |
|||
{ |
|||
Guard.MustBeGreaterThanOrEqualTo(value, min, "myParamName"); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeGreaterThanOrEqualTo_IsLess_ThrowsNoException() |
|||
{ |
|||
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() => |
|||
{ |
|||
Guard.MustBeGreaterThanOrEqualTo(1, 2, "myParamName"); |
|||
}); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"Value 1 must be greater than or equal to 2.", exception.Message); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(1, 1, 3)] |
|||
[InlineData(2, 1, 3)] |
|||
[InlineData(3, 1, 3)] |
|||
public void MustBeBetweenOrEqualTo_IsBetweenOrEqual_ThrowsNoException(int value, int min, int max) |
|||
{ |
|||
Guard.MustBeBetweenOrEqualTo(value, min, max, "myParamName"); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(0, 1, 3)] |
|||
[InlineData(4, 1, 3)] |
|||
public void MustBeBetweenOrEqualTo_IsLessOrGreater_ThrowsNoException(int value, int min, int max) |
|||
{ |
|||
ArgumentOutOfRangeException exception = Assert.Throws<ArgumentOutOfRangeException>(() => |
|||
{ |
|||
Guard.MustBeBetweenOrEqualTo(value, min, max, "myParamName"); |
|||
}); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains($"Value {value} must be greater than or equal to {min} and less than or equal to {max}.", exception.Message); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(2, 1)] |
|||
[InlineData(2, 2)] |
|||
public void MustBeSizedAtLeast_Array_LengthIsGreaterOrEqual_ThrowsNoException(int valueLength, int minLength) |
|||
{ |
|||
Guard.MustBeSizedAtLeast<int>(new int[valueLength], minLength, "myParamName"); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MustBeSizedAtLeast_Array_LengthIsLess_ThrowsException() |
|||
{ |
|||
ArgumentException exception = Assert.Throws<ArgumentException>(() => |
|||
{ |
|||
Guard.MustBeSizedAtLeast<int>(new int[] { 1, 2 }, 3, "myParamName"); |
|||
}); |
|||
|
|||
Assert.Equal("myParamName", exception.ParamName); |
|||
Assert.Contains("The size must be at least 3", exception.Message); |
|||
} |
|||
} |
|||
} |
|||
@ -1,95 +0,0 @@ |
|||
// Copyright (c) Six Labors and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
|
|||
using System; |
|||
using Xunit; |
|||
|
|||
namespace SixLabors.Tests.Helpers |
|||
{ |
|||
public class MathFTests |
|||
{ |
|||
[Fact] |
|||
public void MathF_PI_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.PI, (float)Math.PI); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Ceililng_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Ceiling(0.3333F), (float)Math.Ceiling(0.3333F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Cos_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Cos(0.3333F), (float)Math.Cos(0.3333F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Abs_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Abs(-0.3333F), (float)Math.Abs(-0.3333F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Atan2_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Atan2(1.2345F, 1.2345F), (float)Math.Atan2(1.2345F, 1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Exp_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Exp(1.2345F), (float)Math.Exp(1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Floor_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Floor(1.2345F), (float)Math.Floor(1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Min_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Min(1.2345F, 5.4321F), (float)Math.Min(1.2345F, 5.4321F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Max_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Max(1.2345F, 5.4321F), (float)Math.Max(1.2345F, 5.4321F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Pow_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Pow(1.2345F, 5.4321F), (float)Math.Pow(1.2345F, 5.4321F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Round_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Round(1.2345F), (float)Math.Round(1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Round_With_Midpoint_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Round(1.2345F, MidpointRounding.AwayFromZero), (float)Math.Round(1.2345F, MidpointRounding.AwayFromZero)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Sin_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Sin(1.2345F), (float)Math.Sin(1.2345F)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void MathF_Sqrt_Is_Equal() |
|||
{ |
|||
Assert.Equal(MathF.Sqrt(2F), (float)Math.Sqrt(2F)); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue