mirror of
https://github.com/AssetRipper/AssetRipper.TextureDecoder.git
synced 2026-11-13 04:26:30 -10:00
35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using AssetRipper.TextureDecoder.Rgb;
|
|
using System.Numerics;
|
|
|
|
namespace AssetRipper.TextureDecoder.Tests.Formats.Generic;
|
|
|
|
[TestFixture(TypeArgs = [typeof(sbyte), typeof(byte)])]
|
|
[TestFixture(TypeArgs = [typeof(short), typeof(ushort)])]
|
|
[TestFixture(TypeArgs = [typeof(int), typeof(uint)])]
|
|
[TestFixture(TypeArgs = [typeof(long), typeof(ulong)])]
|
|
[TestFixture(TypeArgs = [typeof(Int128), typeof(UInt128)])]
|
|
internal class NumericConversionExtremesTests<TSigned, TUnsigned>
|
|
where TSigned : unmanaged, IMinMaxValue<TSigned>
|
|
where TUnsigned : unmanaged, IMinMaxValue<TUnsigned>
|
|
{
|
|
[Test]
|
|
public void SignedToUnsignedExtremesAreCorrect()
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(NumericConversion.Convert<TSigned, TUnsigned>(TSigned.MinValue), Is.EqualTo(TUnsigned.MinValue));
|
|
Assert.That(NumericConversion.Convert<TSigned, TUnsigned>(TSigned.MaxValue), Is.EqualTo(TUnsigned.MaxValue));
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void UnsignedToSignedExtremesAreCorrect()
|
|
{
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(NumericConversion.Convert<TUnsigned, TSigned>(TUnsigned.MinValue), Is.EqualTo(TSigned.MinValue));
|
|
Assert.That(NumericConversion.Convert<TUnsigned, TSigned>(TUnsigned.MaxValue), Is.EqualTo(TSigned.MaxValue));
|
|
});
|
|
}
|
|
}
|