FixedPoint2 tweaks (#12431)

This commit is contained in:
Leon Friedrich
2022-11-08 12:14:13 +13:00
committed by GitHub
parent f6e5790b72
commit 5cade18119
2 changed files with 42 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Content.Shared.FixedPoint;
using NUnit.Framework;
@@ -125,6 +125,42 @@ namespace Content.Tests.Shared.Chemistry
Assert.That(min, Is.EqualTo(FixedPoint2.New(1)));
}
[Test]
[TestCase(10.1f, 2.5f, "25.25")]
public void FloatMultiply (float aFloat, float b, string expected)
{
var a = FixedPoint2.New(aFloat);
var result = a*b;
Assert.That($"{result}", Is.EqualTo(expected));
}
[Test]
[TestCase(10.1f, 2.5d, "25.25")]
public void DoubleMultiply(float aFloat, double b, string expected)
{
var a = FixedPoint2.New(aFloat);
var result = a * b;
Assert.That($"{result}", Is.EqualTo(expected));
}
[Test]
[TestCase(10.1f, 2.5f, "4.04")]
public void FloatDivide(float aFloat, float b, string expected)
{
var a = FixedPoint2.New(aFloat);
var result = a / b;
Assert.That($"{result}", Is.EqualTo(expected));
}
[Test]
[TestCase(10.1f, 2.5d, "4.04")]
public void DoubleDivide(float aFloat, double b, string expected)
{
var a = FixedPoint2.New(aFloat);
var result = a / b;
Assert.That($"{result}", Is.EqualTo(expected));
}
[Test]
[TestCase(1, 0, false)]
[TestCase(0, 0, true)]