1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-22 19:48:46 +00:00

Code cleanup for X10D.Tests

This commit is contained in:
Oliver Booth 2022-06-01 15:35:00 +01:00
parent e182b0f821
commit b5227f58d3
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
12 changed files with 23 additions and 22 deletions

View File

@ -10,7 +10,7 @@ public class Int16Tests
public void UnpackBits_ShouldUnpackToArrayCorrectly()
{
bool[] bits = ((short)0b11010100).Unpack();
Assert.AreEqual(16, bits.Length);
Assert.IsFalse(bits[0]);

View File

@ -10,7 +10,7 @@ public class Int32Tests
public void UnpackBits_ShouldUnpackToArrayCorrectly()
{
bool[] bits = 0b11010100.Unpack();
Assert.AreEqual(32, bits.Length);
Assert.IsFalse(bits[0]);

View File

@ -11,7 +11,7 @@ public class EnumTests
// it's clearly Monday as defined by ISO 8601.
// but Microsoft can't fix this without breaking compatibility.
// I have feelings...
[TestMethod]
public void Next()
{
@ -23,7 +23,7 @@ public class EnumTests
Assert.AreEqual(DayOfWeek.Saturday, DayOfWeek.Friday.Next());
Assert.AreEqual(DayOfWeek.Sunday, DayOfWeek.Saturday.Next()); // Saturday is the "last" day. wrap to "first"
}
[TestMethod]
public void NextUnchecked()
{
@ -35,7 +35,7 @@ public class EnumTests
Assert.AreEqual(DayOfWeek.Saturday, DayOfWeek.Friday.NextUnchecked());
Assert.ThrowsException<IndexOutOfRangeException>(() => DayOfWeek.Saturday.NextUnchecked());
}
[TestMethod]
public void Previous()
{
@ -47,7 +47,7 @@ public class EnumTests
Assert.AreEqual(DayOfWeek.Thursday, DayOfWeek.Friday.Previous());
Assert.AreEqual(DayOfWeek.Friday, DayOfWeek.Saturday.Previous());
}
[TestMethod]
public void PreviousUnchecked()
{

View File

@ -10,7 +10,7 @@ public class Int16Tests
public void ProductShouldBeCorrect()
{
short Cast(int i) => (short)i;
Assert.AreEqual(0, Enumerable.Range(0, 10).Select(Cast).Product());
Assert.AreEqual(1, Enumerable.Range(1, 1).Select(Cast).Product());
Assert.AreEqual(2, Enumerable.Range(1, 2).Select(Cast).Product());

View File

@ -35,7 +35,7 @@ public class Int16Tests
{
const short one = 1;
const short two = 2;
Assert.IsFalse(one.IsEven());
Assert.IsTrue(two.IsEven());
}
@ -45,7 +45,7 @@ public class Int16Tests
{
const short one = 1;
const short two = 2;
Assert.IsTrue(one.IsOdd());
Assert.IsFalse(two.IsOdd());
}

View File

@ -35,7 +35,7 @@ public class Int32Tests
{
const int one = 1;
const int two = 2;
Assert.IsFalse(one.IsEven());
Assert.IsTrue(two.IsEven());
}
@ -45,7 +45,7 @@ public class Int32Tests
{
const int one = 1;
const int two = 2;
Assert.IsTrue(one.IsOdd());
Assert.IsFalse(two.IsOdd());
}

View File

@ -35,7 +35,7 @@ public class Int64Tests
{
const long one = 1;
const long two = 2;
Assert.IsFalse(one.IsEven());
Assert.IsTrue(two.IsEven());
}
@ -45,7 +45,7 @@ public class Int64Tests
{
const long one = 1;
const long two = 2;
Assert.IsTrue(one.IsOdd());
Assert.IsFalse(two.IsOdd());
}

View File

@ -14,7 +14,7 @@ public class UInt16Tests
Assert.AreEqual(4, value.DigitalRoot());
Assert.AreEqual(4, (-value).DigitalRoot());
}
[TestMethod]
public void FactorialShouldBeCorrect()
{
@ -36,7 +36,7 @@ public class UInt16Tests
{
const ushort one = 1;
const ushort two = 2;
Assert.IsFalse(one.IsEven());
Assert.IsTrue(two.IsEven());
}
@ -46,7 +46,7 @@ public class UInt16Tests
{
const ushort one = 1;
const ushort two = 2;
Assert.IsTrue(one.IsOdd());
Assert.IsFalse(two.IsOdd());
}

View File

@ -40,7 +40,7 @@ public class UInt64Tests
{
const ulong one = 1;
const ulong two = 2;
Assert.IsFalse(one.IsEven());
Assert.IsTrue(two.IsEven());
}
@ -50,7 +50,7 @@ public class UInt64Tests
{
const ulong one = 1;
const ulong two = 2;
Assert.IsTrue(one.IsOdd());
Assert.IsFalse(two.IsOdd());
}

View File

@ -56,7 +56,7 @@ public class Int16Tests
{
for (var i = 0; i < 8; i++)
{
var value = (short) System.Math.Pow(2, i);
var value = (short)System.Math.Pow(2, i);
Assert.AreEqual(value, value.RoundUpToPowerOf2());
}
}

View File

@ -39,7 +39,9 @@ public class UInt32Tests
{
const uint value = 284719; // 00000000 00000100 01011000 00101111
Assert.AreEqual(value, value.RotateRight(32));
} [TestMethod]
}
[TestMethod]
public void RoundUpToPowerOf2_ShouldReturnRoundedValue_GivenValue()
{
Assert.AreEqual(4U, 3U.RoundUpToPowerOf2());

View File

@ -1,5 +1,4 @@
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using X10D.Text;
namespace X10D.Tests.Text;