Add unit tests for `NumberExtensions.Log10`

This commit is contained in:
YoshiRulz 2025-02-13 22:15:38 +10:00
parent d9d1bfd1e8
commit cf70cc9ef4
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,33 @@
using NE = BizHawk.Common.NumberExtensions.NumberExtensions;
namespace BizHawk.Tests.Common.NumberExtensions
{
[TestClass]
public class StringExtensionTests
{
[DataRow(int.MinValue, -1)]
[DataRow(-1, -1)]
[DataRow(0, -1)]
[DataRow(1, 0)]
[DataRow(2, 0)]
[DataRow(9, 0)]
[DataRow(10, 1)]
[DataRow(11, 1)]
[DataRow(99, 1)]
[DataRow(100, 2)]
[DataRow(101, 2)]
[DataRow(999, 2)]
[DataRow(1000, 3)]
[DataRow(1001, 3)]
[DataRow(9999, 3)]
[DataRow(10000, 4)]
[DataRow(10001, 4)]
[TestMethod]
public void TestLog10(int input, int expected)
{
var actual = NE.Log10(input);
Assert.AreEqual(expected, actual, "should match docs");
if (expected >= 0) Assert.AreEqual(unchecked((int) Math.Log10(input)), actual, "should match BCL");
}
}
}