1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-23 10:08:00 +02:00

Add ability to get min/max values for generic int's and uint's

This commit is contained in:
Ron Zuckerman 2024-02-08 20:16:29 -06:00
parent 6302416e40
commit 484b9716db
No known key found for this signature in database
GPG key ID: 7EC17CB87028ABF8
12 changed files with 72 additions and 10 deletions

View file

@ -113,5 +113,29 @@ namespace Tests
Uint64ParseErrorTest("+0x", .HexNumber);
Uint64ParseErrorTest("+0X", .HexNumber);
}
public static void MinMaxTest<T>(T expectedMinValue, T expectedMaxValue)
where T : IMinMaxValue<T>
where int : operator T <=> T
{
Test.Assert(T.MinValue == expectedMinValue);
Test.Assert(T.MaxValue == expectedMaxValue);
}
[Test]
public static void TestMinMax()
{
MinMaxTest<int>(Int.MinValue, Int.MaxValue);
MinMaxTest<int8>(Int8.MinValue, Int8.MaxValue);
MinMaxTest<int16>(Int16.MinValue, Int16.MaxValue);
MinMaxTest<int32>(Int32.MinValue, Int32.MaxValue);
MinMaxTest<int64>(Int64.MinValue, Int64.MaxValue);
MinMaxTest<uint>(UInt.MinValue, UInt.MaxValue);
MinMaxTest<uint8>(UInt8.MinValue, UInt8.MaxValue);
MinMaxTest<uint16>(UInt16.MinValue, UInt16.MaxValue);
MinMaxTest<uint32>(UInt32.MinValue, UInt32.MaxValue);
MinMaxTest<uint64>(UInt64.MinValue, UInt64.MaxValue);
}
}
}