1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 22:55:42 +00:00
X10D/X10D.Tests/src/Math/UInt64Tests.Wrap.cs

105 lines
2.5 KiB
C#
Raw Permalink Normal View History

2023-08-26 18:11:29 +01:00
using NUnit.Framework;
using X10D.Math;
namespace X10D.Tests.Math;
internal partial class UInt64Tests
{
[TestFixture]
public class WrapTests
{
[Test]
public void Wrap_ShouldReturnLow_WhenValueIsEqualToLow()
{
const ulong value = 10;
const ulong low = 10;
const ulong high = 20;
ulong result = value.Wrap(low, high);
Assert.That(result, Is.EqualTo(low));
}
[Test]
public void Wrap_ShouldReturnHigh_WhenValueIsEqualToHigh()
{
const ulong value = 20;
const ulong low = 10;
const ulong high = 20;
ulong result = value.Wrap(low, high);
Assert.That(result, Is.EqualTo(low));
}
[Test]
public void Wrap_ShouldReturnCorrectResult_WhenValueIsGreaterThanHigh()
{
const ulong value = 30;
const ulong low = 10;
const ulong high = 20;
ulong result = value.Wrap(low, high);
Assert.That(result, Is.EqualTo(low));
}
[Test]
public void Wrap_ShouldReturnCorrectResult_WhenValueIsLessThanLow()
{
const ulong value = 5;
const ulong low = 10;
const ulong high = 20;
ulong result = value.Wrap(low, high);
Assert.That(result, Is.EqualTo(11UL));
}
[Test]
public void Wrap_ShouldReturnCorrectResult_WhenValueIsInBetweenLowAndHigh()
{
const ulong value = 15;
const ulong low = 10;
const ulong high = 20;
ulong result = value.Wrap(low, high);
Assert.That(result, Is.EqualTo(value));
}
[Test]
public void Wrap_ShouldReturnZero_WhenValueIsEqualToLength()
{
const ulong value = 10;
const ulong length = 10;
ulong result = value.Wrap(length);
Assert.That(result, Is.EqualTo(0UL));
}
[Test]
public void Wrap_ShouldReturnValue_WhenValueIsLessThanLength()
{
const ulong value = 5;
const ulong length = 10;
ulong result = value.Wrap(length);
Assert.That(result, Is.EqualTo(value));
}
[Test]
public void Wrap_ShouldReturnCorrectResult_WhenValueIsGreaterThanLength()
{
const ulong value = 15;
const ulong length = 10;
ulong result = value.Wrap(length);
Assert.That(result, Is.EqualTo(5UL));
}
}
}