diff --git a/X10D.Tests/src/Collections/BoolListTests.cs b/X10D.Tests/src/Collections/BoolListTests.cs index e844c4e..e67aafc 100644 --- a/X10D.Tests/src/Collections/BoolListTests.cs +++ b/X10D.Tests/src/Collections/BoolListTests.cs @@ -10,47 +10,47 @@ public class BoolListTests public void Pack8Bit_Should_Pack_Correctly() { var array = new[] {true, false, true, false, true, false, true, false}; - Assert.AreEqual(85, array.Pack8Bit()); // 01010101 + Assert.AreEqual(85, array.PackByte()); // 01010101 } [TestMethod] public void Pack16Bit_Should_Pack_Correctly() { var array = new[] {true, false, true, false, true, false, true, false, true, true, false, true}; - Assert.AreEqual(2901, array.Pack16Bit()); // 101101010101 + Assert.AreEqual(2901, array.PackInt16()); // 101101010101 } [TestMethod] public void Pack32Bit_Should_Pack_Correctly() { var array = new[] {true, false, true, false, true, false, true, false, true, true, false, true}; - Assert.AreEqual(2901, array.Pack32Bit()); // 101101010101 + Assert.AreEqual(2901, array.PackInt32()); // 101101010101 } [TestMethod] public void Pack64Bit_Should_Pack_Correctly() { var array = new[] {true, false, true, false, true, false, true, false, true, true, false, true}; - Assert.AreEqual(2901, array.Pack64Bit()); // 101101010101 + Assert.AreEqual(2901, array.PackInt64()); // 101101010101 } [TestMethod] public void Pack_ShouldThrow_GivenLargeArray() { bool[] array = Enumerable.Repeat(false, 65).ToArray(); - Assert.ThrowsException(() => array.Pack8Bit()); - Assert.ThrowsException(() => array.Pack16Bit()); - Assert.ThrowsException(() => array.Pack32Bit()); - Assert.ThrowsException(() => array.Pack64Bit()); + Assert.ThrowsException(() => array.PackByte()); + Assert.ThrowsException(() => array.PackInt16()); + Assert.ThrowsException(() => array.PackInt32()); + Assert.ThrowsException(() => array.PackInt64()); } [TestMethod] public void Pack_ShouldThrow_GivenNull() { bool[]? array = null; - Assert.ThrowsException(() => array!.Pack8Bit()); - Assert.ThrowsException(() => array!.Pack16Bit()); - Assert.ThrowsException(() => array!.Pack32Bit()); - Assert.ThrowsException(() => array!.Pack64Bit()); + Assert.ThrowsException(() => array!.PackByte()); + Assert.ThrowsException(() => array!.PackInt16()); + Assert.ThrowsException(() => array!.PackInt32()); + Assert.ThrowsException(() => array!.PackInt64()); } } diff --git a/X10D.Tests/src/Collections/ByteTests.cs b/X10D.Tests/src/Collections/ByteTests.cs index 90a5db6..15c28a8 100644 --- a/X10D.Tests/src/Collections/ByteTests.cs +++ b/X10D.Tests/src/Collections/ByteTests.cs @@ -9,7 +9,7 @@ public class ByteTests [TestMethod] public void UnpackBits_ShouldUnpackToArrayCorrectly() { - bool[] bits = ((byte)0b11010100).UnpackBits(); + bool[] bits = ((byte)0b11010100).Unpack(); Assert.AreEqual(8, bits.Length); @@ -27,7 +27,7 @@ public class ByteTests public void UnpackBits_ShouldUnpackToSpanCorrectly() { Span bits = stackalloc bool[8]; - ((byte)0b11010100).UnpackBits(bits); + ((byte)0b11010100).Unpack(bits); Assert.IsFalse(bits[0]); Assert.IsFalse(bits[1]); @@ -42,7 +42,7 @@ public class ByteTests [TestMethod] public void UnpackBits_ShouldRepackEqually() { - Assert.AreEqual(0b11010100, ((byte)0b11010100).UnpackBits().Pack8Bit()); + Assert.AreEqual(0b11010100, ((byte)0b11010100).Unpack().PackByte()); } [TestMethod] @@ -51,7 +51,7 @@ public class ByteTests Assert.ThrowsException(() => { Span bits = stackalloc bool[0]; - ((byte)0b11010100).UnpackBits(bits); + ((byte)0b11010100).Unpack(bits); }); } } diff --git a/X10D.Tests/src/Collections/Int16Tests.cs b/X10D.Tests/src/Collections/Int16Tests.cs index b2e526f..d077744 100644 --- a/X10D.Tests/src/Collections/Int16Tests.cs +++ b/X10D.Tests/src/Collections/Int16Tests.cs @@ -9,7 +9,7 @@ public class Int16Tests [TestMethod] public void UnpackBits_ShouldUnpackToArrayCorrectly() { - bool[] bits = ((short)0b11010100).UnpackBits(); + bool[] bits = ((short)0b11010100).Unpack(); Assert.AreEqual(16, bits.Length); @@ -32,7 +32,7 @@ public class Int16Tests public void UnpackBits_ShouldUnpackToSpanCorrectly() { Span bits = stackalloc bool[16]; - ((short)0b11010100).UnpackBits(bits); + ((short)0b11010100).Unpack(bits); Assert.IsFalse(bits[0]); Assert.IsFalse(bits[1]); @@ -52,7 +52,7 @@ public class Int16Tests [TestMethod] public void UnpackBits_ShouldRepackEqually() { - Assert.AreEqual(0b11010100, ((short)0b11010100).UnpackBits().Pack16Bit()); + Assert.AreEqual(0b11010100, ((short)0b11010100).Unpack().PackInt16()); } [TestMethod] @@ -61,7 +61,7 @@ public class Int16Tests Assert.ThrowsException(() => { Span bits = stackalloc bool[0]; - ((short)0b11010100).UnpackBits(bits); + ((short)0b11010100).Unpack(bits); }); } } diff --git a/X10D.Tests/src/Collections/Int32Tests.cs b/X10D.Tests/src/Collections/Int32Tests.cs index 3dd6b0d..cd86c75 100644 --- a/X10D.Tests/src/Collections/Int32Tests.cs +++ b/X10D.Tests/src/Collections/Int32Tests.cs @@ -9,7 +9,7 @@ public class Int32Tests [TestMethod] public void UnpackBits_ShouldUnpackToArrayCorrectly() { - bool[] bits = 0b11010100.UnpackBits(); + bool[] bits = 0b11010100.Unpack(); Assert.AreEqual(32, bits.Length); @@ -32,7 +32,7 @@ public class Int32Tests public void UnpackBits_ShouldUnpackToSpanCorrectly() { Span bits = stackalloc bool[32]; - 0b11010100.UnpackBits(bits); + 0b11010100.Unpack(bits); Assert.IsFalse(bits[0]); Assert.IsFalse(bits[1]); @@ -52,7 +52,7 @@ public class Int32Tests [TestMethod] public void UnpackBits_ShouldRepackEqually() { - Assert.AreEqual(0b11010100, 0b11010100.UnpackBits().Pack32Bit()); + Assert.AreEqual(0b11010100, 0b11010100.Unpack().PackInt32()); } [TestMethod] @@ -61,7 +61,7 @@ public class Int32Tests Assert.ThrowsException(() => { Span bits = stackalloc bool[0]; - 0b11010100.UnpackBits(bits); + 0b11010100.Unpack(bits); }); } } diff --git a/X10D.Tests/src/Collections/Int64Tests.cs b/X10D.Tests/src/Collections/Int64Tests.cs index 31c3b6e..2622863 100644 --- a/X10D.Tests/src/Collections/Int64Tests.cs +++ b/X10D.Tests/src/Collections/Int64Tests.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using Microsoft.VisualStudio.TestTools.UnitTesting; using X10D.Collections; -using X10D.Linq; namespace X10D.Tests.Collections; @@ -11,7 +10,7 @@ public class Int64Tests [TestMethod] public void UnpackBits_ShouldUnpackToArrayCorrectly() { - bool[] bits = 0b11010100L.UnpackBits(); + bool[] bits = 0b11010100L.Unpack(); Assert.AreEqual(64, bits.Length); @@ -37,7 +36,7 @@ public class Int64Tests public void UnpackBits_ShouldUnpackToSpanCorrectly() { Span bits = stackalloc bool[64]; - 0b11010100L.UnpackBits(bits); + 0b11010100L.Unpack(bits); Assert.IsFalse(bits[0]); Assert.IsFalse(bits[1]); @@ -57,7 +56,7 @@ public class Int64Tests [TestMethod] public void UnpackBits_ShouldRepackEqually() { - Assert.AreEqual(0b11010100L, 0b11010100L.UnpackBits().Pack64Bit()); + Assert.AreEqual(0b11010100L, 0b11010100L.Unpack().PackInt64()); } [TestMethod] @@ -66,7 +65,7 @@ public class Int64Tests Assert.ThrowsException(() => { Span bits = stackalloc bool[0]; - 0b11010100L.UnpackBits(bits); + 0b11010100L.Unpack(bits); }); } } diff --git a/X10D/src/Collections/BoolListExtensions.cs b/X10D/src/Collections/BoolListExtensions.cs index 7e3e806..7ee204a 100644 --- a/X10D/src/Collections/BoolListExtensions.cs +++ b/X10D/src/Collections/BoolListExtensions.cs @@ -1,4 +1,4 @@ -namespace X10D.Collections; +namespace X10D.Collections; /// /// Collection-related extension methods for of . @@ -13,7 +13,7 @@ public static class BoolListExtensions /// is . /// contains more than 8 elements. /// Alpha Anar - public static byte Pack8Bit(this IReadOnlyList source) + public static byte PackByte(this IReadOnlyList source) { if (source is null) { @@ -42,7 +42,7 @@ public static class BoolListExtensions /// A 16-bit signed integer containing the packed booleans. /// is . /// contains more than 16 elements. - public static short Pack16Bit(this IReadOnlyList source) + public static short PackInt16(this IReadOnlyList source) { if (source is null) { @@ -71,7 +71,7 @@ public static class BoolListExtensions /// A 32-bit signed integer containing the packed booleans. /// is . /// contains more than 32 elements. - public static int Pack32Bit(this IReadOnlyList source) + public static int PackInt32(this IReadOnlyList source) { if (source is null) { @@ -100,7 +100,7 @@ public static class BoolListExtensions /// A 64-bit signed integer containing the packed booleans. /// is . /// contains more than 64 elements. - public static long Pack64Bit(this IReadOnlyList source) + public static long PackInt64(this IReadOnlyList source) { if (source is null) { diff --git a/X10D/src/Collections/ByteExtensions.cs b/X10D/src/Collections/ByteExtensions.cs index fe7e1b0..c873ccc 100644 --- a/X10D/src/Collections/ByteExtensions.cs +++ b/X10D/src/Collections/ByteExtensions.cs @@ -12,10 +12,10 @@ public static class ByteExtensions /// /// The value to unpack. /// An array of with length 8. - public static bool[] UnpackBits(this byte value) + public static bool[] Unpack(this byte value) { Span buffer = stackalloc bool[Size]; - value.UnpackBits(buffer); + value.Unpack(buffer); return buffer.ToArray(); } @@ -26,7 +26,7 @@ public static class ByteExtensions /// When this method returns, contains the unpacked booleans from . /// is not large enough to contain the result. /// Alpha Anar - public static void UnpackBits(this byte value, Span destination) + public static void Unpack(this byte value, Span destination) { if (destination.Length < Size) { diff --git a/X10D/src/Collections/Int16Extensions.cs b/X10D/src/Collections/Int16Extensions.cs index 3b72c16..2bba901 100644 --- a/X10D/src/Collections/Int16Extensions.cs +++ b/X10D/src/Collections/Int16Extensions.cs @@ -12,10 +12,10 @@ public static class Int16Extensions /// /// The value to unpack. /// An array of with length 16. - public static bool[] UnpackBits(this short value) + public static bool[] Unpack(this short value) { Span buffer = stackalloc bool[Size]; - value.UnpackBits(buffer); + value.Unpack(buffer); return buffer.ToArray(); } @@ -25,13 +25,13 @@ public static class Int16Extensions /// The value to unpack. /// When this method returns, contains the unpacked booleans from . /// is not large enough to contain the result. - public static void UnpackBits(this short value, Span destination) + public static void Unpack(this short value, Span destination) { if (destination.Length < Size) { throw new ArgumentException($"Destination must be at least {Size} in length.", nameof(destination)); } - + for (var index = 0; index < Size; index++) { destination[index] = (value & (1 << index)) != 0; diff --git a/X10D/src/Collections/Int32Extensions.cs b/X10D/src/Collections/Int32Extensions.cs index b61c54e..07a8db1 100644 --- a/X10D/src/Collections/Int32Extensions.cs +++ b/X10D/src/Collections/Int32Extensions.cs @@ -12,10 +12,10 @@ public static class Int32Extensions /// /// The value to unpack. /// An array of with length 32. - public static bool[] UnpackBits(this int value) + public static bool[] Unpack(this int value) { Span buffer = stackalloc bool[Size]; - value.UnpackBits(buffer); + value.Unpack(buffer); return buffer.ToArray(); } @@ -25,13 +25,13 @@ public static class Int32Extensions /// The value to unpack. /// When this method returns, contains the unpacked booleans from . /// is not large enough to contain the result. - public static void UnpackBits(this int value, Span destination) + public static void Unpack(this int value, Span destination) { if (destination.Length < Size) { throw new ArgumentException($"Destination must be at least {Size} in length.", nameof(destination)); } - + for (var index = 0; index < Size; index++) { destination[index] = (value & (1 << index)) != 0; diff --git a/X10D/src/Collections/Int64Extensions.cs b/X10D/src/Collections/Int64Extensions.cs index 848d4e2..26a80b4 100644 --- a/X10D/src/Collections/Int64Extensions.cs +++ b/X10D/src/Collections/Int64Extensions.cs @@ -12,10 +12,10 @@ public static class Int64Extensions /// /// The value to unpack. /// An array of with length 64. - public static bool[] UnpackBits(this long value) + public static bool[] Unpack(this long value) { Span buffer = stackalloc bool[Size]; - value.UnpackBits(buffer); + value.Unpack(buffer); return buffer.ToArray(); } @@ -25,7 +25,7 @@ public static class Int64Extensions /// The value to unpack. /// When this method returns, contains the unpacked booleans from . /// is not large enough to contain the result. - public static void UnpackBits(this long value, Span destination) + public static void Unpack(this long value, Span destination) { if (destination.Length < Size) {