mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:45:42 +00:00
Code cleanup for X10D.Tests
This commit is contained in:
parent
e182b0f821
commit
b5227f58d3
@ -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]);
|
||||
|
@ -10,7 +10,7 @@ public class Int32Tests
|
||||
public void UnpackBits_ShouldUnpackToArrayCorrectly()
|
||||
{
|
||||
bool[] bits = 0b11010100.Unpack();
|
||||
|
||||
|
||||
Assert.AreEqual(32, bits.Length);
|
||||
|
||||
Assert.IsFalse(bits[0]);
|
||||
|
@ -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()
|
||||
{
|
||||
|
@ -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());
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using X10D.Text;
|
||||
|
||||
namespace X10D.Tests.Text;
|
||||
|
Loading…
Reference in New Issue
Block a user