From f3afeaf84efe655ac48e0ef688569057c5f5abf2 Mon Sep 17 00:00:00 2001 From: "Robert H. Engelhardt" Date: Sat, 12 Oct 2019 22:44:25 -0600 Subject: [PATCH] Formatting and fixed analyzer bug fixed "AD0001 Analyzer 'Microsoft.NetCore.Analyzers.Security.DoNotHardCodeEncryptionKey' threw an exception of type 'System.NotSupportedException'" issue thanks to https://david.gardiner.net.au/2016/08/error-ad0001-compiler-analyzer-threw.html --- src/Gulliver.Tests/ByteArrayUtilsTests.cs | 150 ++++---- .../ByteArrayUtils_BigEndian_Tests.cs | 116 +++--- .../ByteArrayUtils_Conversion_Tests.cs | 60 +-- .../ByteArrayUtils_LittleEndian_Tests.cs | 116 +++--- .../BigEndianByteEnumerableTests.cs | 16 +- .../ConcurrentBigEndianByteEnumerableTests.cs | 18 +- ...ncurrentLittleEndianByteEnumerableTests.cs | 18 +- .../LittleEndianByteEnumerableTests.cs | 16 +- src/Gulliver.Tests/FixedBytesTests.cs | 346 +++++++++--------- src/Gulliver.Tests/Gulliver.Tests.csproj | 3 + src/Gulliver/ByteArrayUtils.cs | 10 +- src/Gulliver/ByteArrayUtils_BigEndian.cs | 18 +- src/Gulliver/ByteArrayUtils_Conversion.cs | 2 +- src/Gulliver/ByteArrayUtils_LittleEndian.cs | 18 +- .../ConcurrentBigEndianByteEnumerable.cs | 64 ++-- .../ConcurrentLittleEndianByteEnumerable.cs | 64 ++-- src/Gulliver/FixedBytes.cs | 2 +- 17 files changed, 520 insertions(+), 517 deletions(-) diff --git a/src/Gulliver.Tests/ByteArrayUtilsTests.cs b/src/Gulliver.Tests/ByteArrayUtilsTests.cs index f558c32..76d0e07 100644 --- a/src/Gulliver.Tests/ByteArrayUtilsTests.cs +++ b/src/Gulliver.Tests/ByteArrayUtilsTests.cs @@ -65,7 +65,7 @@ public ByteArrayUtilsTests(ITestOutputHelper testOutputHelper) foreach (var i in Enumerable.Range(0, 5)) { - yield return (uint) i; + yield return (uint)i; } } } @@ -150,7 +150,7 @@ IEnumerable TestCases() ? BitConverter.GetBytes(u.Value) : Array.Empty(); - yield return new object[] {expected, bytes}; + yield return new object[] { expected, bytes }; } } } @@ -214,9 +214,9 @@ public static IEnumerable AddressBit_Values() { for (var i = 0; i < 8; i++) { - yield return new object[] {true, i, new byte[] {(byte) (0x01 << i), 0x00}}; - yield return new object[] {true, i + 8, new byte[] {0x00, (byte) (0x01 << i)}}; - yield return new object[] {false, i, new[] {(byte) ~(0x01 << i)}}; + yield return new object[] { true, i, new byte[] { (byte)(0x01 << i), 0x00 } }; + yield return new object[] { true, i + 8, new byte[] { 0x00, (byte)(0x01 << i) } }; + yield return new object[] { false, i, new[] { (byte)~(0x01 << i) } }; } } @@ -241,7 +241,7 @@ public void AddressBit_Test(bool expected, public void AddressBit_NullInput_ThrowsArgumentNullException_Test() { // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).AddressBit(default)); + Assert.Throws(() => ((byte[])null).AddressBit(default)); } [Theory] @@ -250,7 +250,7 @@ public void AddressBit_NullInput_ThrowsArgumentNullException_Test() public void AddressBit_IndexOutOfRange_ThrowsArgumentOutOfRangeException_Test(int index) { // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => new byte[] {0xff}.AddressBit(index)); + Assert.Throws(() => new byte[] { 0xff }.AddressBit(index)); } #endregion @@ -260,38 +260,38 @@ public void AddressBit_IndexOutOfRange_ThrowsArgumentOutOfRangeException_Test(in public static IEnumerable ShiftBitsRight_Test_Values() { // nothing to shift, no shifting - yield return new object[] { Array.Empty(), Array.Empty(), Array.Empty(), 0}; + yield return new object[] { Array.Empty(), Array.Empty(), Array.Empty(), 0 }; // no shifting - yield return new object[] { Array.Empty(), Array.Empty(), Array.Empty(), 8}; - yield return new object[] {new byte[] {0xac}, Array.Empty(), new byte[] {0xac}, 0}; + yield return new object[] { Array.Empty(), Array.Empty(), Array.Empty(), 8 }; + yield return new object[] { new byte[] { 0xac }, Array.Empty(), new byte[] { 0xac }, 0 }; // shift across byte boundary - yield return new object[] {new byte[] {0x00}, new byte[] {0xac}, new byte[] {0xac}, 8}; - yield return new object[] {new byte[] {0x00, 0xca}, new byte[] {0xac}, new byte[] {0xca, 0xac}, 8}; - yield return new object[] {new byte[] {0x00, 0x00}, new byte[] {0xca, 0xac}, new byte[] {0xca, 0xac}, 16}; + yield return new object[] { new byte[] { 0x00 }, new byte[] { 0xac }, new byte[] { 0xac }, 8 }; + yield return new object[] { new byte[] { 0x00, 0xca }, new byte[] { 0xac }, new byte[] { 0xca, 0xac }, 8 }; + yield return new object[] { new byte[] { 0x00, 0x00 }, new byte[] { 0xca, 0xac }, new byte[] { 0xca, 0xac }, 16 }; // far shifting - yield return new object[] {new byte[] {0x00}, new byte[] {0x00, 0x00, 0x00, 0xFF}, new byte[] {0xFF}, 32}; + yield return new object[] { new byte[] { 0x00 }, new byte[] { 0x00, 0x00, 0x00, 0xFF }, new byte[] { 0xFF }, 32 }; // ragged shifting - yield return new object[] {new byte[] {0b0111_1111}, new byte[] {0b1000_0000}, new byte[] {0b1111_1111}, 1}; - yield return new object[] {new byte[] {0b0011_1111}, new byte[] {0b1100_0000}, new byte[] {0b1111_1111}, 2}; - yield return new object[] {new byte[] {0b0001_1111}, new byte[] {0b1110_0000}, new byte[] {0b1111_1111}, 3}; - yield return new object[] {new byte[] {0b0000_1111}, new byte[] {0b1111_0000}, new byte[] {0b1111_1111}, 4}; - yield return new object[] {new byte[] {0b0000_0111}, new byte[] {0b1111_1000}, new byte[] {0b1111_1111}, 5}; - yield return new object[] {new byte[] {0b0000_0011}, new byte[] {0b1111_1100}, new byte[] {0b1111_1111}, 6}; - yield return new object[] {new byte[] {0b0000_0001}, new byte[] {0b1111_1110}, new byte[] {0b1111_1111}, 7}; + yield return new object[] { new byte[] { 0b0111_1111 }, new byte[] { 0b1000_0000 }, new byte[] { 0b1111_1111 }, 1 }; + yield return new object[] { new byte[] { 0b0011_1111 }, new byte[] { 0b1100_0000 }, new byte[] { 0b1111_1111 }, 2 }; + yield return new object[] { new byte[] { 0b0001_1111 }, new byte[] { 0b1110_0000 }, new byte[] { 0b1111_1111 }, 3 }; + yield return new object[] { new byte[] { 0b0000_1111 }, new byte[] { 0b1111_0000 }, new byte[] { 0b1111_1111 }, 4 }; + yield return new object[] { new byte[] { 0b0000_0111 }, new byte[] { 0b1111_1000 }, new byte[] { 0b1111_1111 }, 5 }; + yield return new object[] { new byte[] { 0b0000_0011 }, new byte[] { 0b1111_1100 }, new byte[] { 0b1111_1111 }, 6 }; + yield return new object[] { new byte[] { 0b0000_0001 }, new byte[] { 0b1111_1110 }, new byte[] { 0b1111_1111 }, 7 }; - yield return new object[] {new byte[] {0b0000_0000}, new byte[] {0b0000_1111, 0b1111_0000}, new byte[] {0b1111_1111}, 12}; - yield return new object[] {new byte[] {0b0000_0000}, new byte[] {0b0000_0001, 0b1111_1110}, new byte[] {0b1111_1111}, 15}; + yield return new object[] { new byte[] { 0b0000_0000 }, new byte[] { 0b0000_1111, 0b1111_0000 }, new byte[] { 0b1111_1111 }, 12 }; + yield return new object[] { new byte[] { 0b0000_0000 }, new byte[] { 0b0000_0001, 0b1111_1110 }, new byte[] { 0b1111_1111 }, 15 }; - yield return new object[] {new byte[] {0b0000_0101}, new byte[] {0b1100_0000}, new byte[] {0b0101_1100}, 4}; - yield return new object[] {new byte[] {0b0000_0101, 0b1100_1100}, new byte[] {0b0011_0000}, new byte[] {0b0101_1100, 0b1100_0011}, 4}; - yield return new object[] {new byte[] {0b0000_0000, 0b0000_0001}, new byte[] {0b1011_1001, 0b1000_0110}, new byte[] {0b1101_1100, 0b1100_0011}, 15}; + yield return new object[] { new byte[] { 0b0000_0101 }, new byte[] { 0b1100_0000 }, new byte[] { 0b0101_1100 }, 4 }; + yield return new object[] { new byte[] { 0b0000_0101, 0b1100_1100 }, new byte[] { 0b0011_0000 }, new byte[] { 0b0101_1100, 0b1100_0011 }, 4 }; + yield return new object[] { new byte[] { 0b0000_0000, 0b0000_0001 }, new byte[] { 0b1011_1001, 0b1000_0110 }, new byte[] { 0b1101_1100, 0b1100_0011 }, 15 }; // ragged far shift - yield return new object[] {new byte[] {0x00}, new byte[] {0x00, 0x00, 0x01, 0xFE}, new byte[] {0xFF}, 31}; + yield return new object[] { new byte[] { 0x00 }, new byte[] { 0x00, 0x00, 0x01, 0xFE }, new byte[] { 0xFF }, 31 }; } [Theory] @@ -324,20 +324,20 @@ public void ShiftBitsRight_Test(byte[] expected, public void ShiftBitsRight_NullInput_ThrowsArgumentNullException_Test() { // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).ShiftBitsRight(42, out _)); + Assert.Throws(() => ((byte[])null).ShiftBitsRight(42, out _)); // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).ShiftBitsRight(42)); + Assert.Throws(() => ((byte[])null).ShiftBitsRight(42)); } [Fact] public void ShiftBitsRight_ShiftLessThanZero_ThrowsArgumentOutOfRangeException_Test() { // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => new byte[] {0x00}.ShiftBitsRight(-1, out _)); + Assert.Throws(() => new byte[] { 0x00 }.ShiftBitsRight(-1, out _)); // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => new byte[] {0x00}.ShiftBitsRight(-1)); + Assert.Throws(() => new byte[] { 0x00 }.ShiftBitsRight(-1)); } #endregion @@ -347,40 +347,40 @@ public void ShiftBitsRight_ShiftLessThanZero_ThrowsArgumentOutOfRangeException_T public static IEnumerable ShiftBitsLeft_Test_Values() { // nothing to shift, no shifting - yield return new object[] { Array.Empty(), Array.Empty(), Array.Empty(), 0}; + yield return new object[] { Array.Empty(), Array.Empty(), Array.Empty(), 0 }; // no shifting - yield return new object[] { Array.Empty(), Array.Empty(), Array.Empty(), 8}; - yield return new object[] {new byte[] {0xac}, Array.Empty(), new byte[] {0xac}, 0}; + yield return new object[] { Array.Empty(), Array.Empty(), Array.Empty(), 8 }; + yield return new object[] { new byte[] { 0xac }, Array.Empty(), new byte[] { 0xac }, 0 }; // shift across byte boundary - yield return new object[] {new byte[] {0x00}, new byte[] {0xac}, new byte[] {0xac}, 8}; - yield return new object[] {new byte[] {0xac, 0x00}, new byte[] {0xca}, new byte[] {0xca, 0xac}, 8}; - yield return new object[] {new byte[] {0x00, 0x00}, new byte[] {0xca, 0xac}, new byte[] {0xca, 0xac}, 16}; + yield return new object[] { new byte[] { 0x00 }, new byte[] { 0xac }, new byte[] { 0xac }, 8 }; + yield return new object[] { new byte[] { 0xac, 0x00 }, new byte[] { 0xca }, new byte[] { 0xca, 0xac }, 8 }; + yield return new object[] { new byte[] { 0x00, 0x00 }, new byte[] { 0xca, 0xac }, new byte[] { 0xca, 0xac }, 16 }; // far shifting - yield return new object[] {new byte[] {0x00}, new byte[] {0xFF, 0x00, 0x00, 0x00}, new byte[] {0xFF}, 32}; + yield return new object[] { new byte[] { 0x00 }, new byte[] { 0xFF, 0x00, 0x00, 0x00 }, new byte[] { 0xFF }, 32 }; // ragged shifting - yield return new object[] {new byte[] {0b1111_1110}, new byte[] {0b0000_0001}, new byte[] {0b1111_1111}, 1}; - yield return new object[] {new byte[] {0b1111_1100}, new byte[] {0b0000_0011}, new byte[] {0b1111_1111}, 2}; - yield return new object[] {new byte[] {0b1111_1000}, new byte[] {0b0000_0111}, new byte[] {0b1111_1111}, 3}; - yield return new object[] {new byte[] {0b1111_0000}, new byte[] {0b0000_1111}, new byte[] {0b1111_1111}, 4}; - yield return new object[] {new byte[] {0b1110_0000}, new byte[] {0b0001_1111}, new byte[] {0b1111_1111}, 5}; - yield return new object[] {new byte[] {0b1100_0000}, new byte[] {0b0011_1111}, new byte[] {0b1111_1111}, 6}; - yield return new object[] {new byte[] {0b1000_0000}, new byte[] {0b0111_1111}, new byte[] {0b1111_1111}, 7}; + yield return new object[] { new byte[] { 0b1111_1110 }, new byte[] { 0b0000_0001 }, new byte[] { 0b1111_1111 }, 1 }; + yield return new object[] { new byte[] { 0b1111_1100 }, new byte[] { 0b0000_0011 }, new byte[] { 0b1111_1111 }, 2 }; + yield return new object[] { new byte[] { 0b1111_1000 }, new byte[] { 0b0000_0111 }, new byte[] { 0b1111_1111 }, 3 }; + yield return new object[] { new byte[] { 0b1111_0000 }, new byte[] { 0b0000_1111 }, new byte[] { 0b1111_1111 }, 4 }; + yield return new object[] { new byte[] { 0b1110_0000 }, new byte[] { 0b0001_1111 }, new byte[] { 0b1111_1111 }, 5 }; + yield return new object[] { new byte[] { 0b1100_0000 }, new byte[] { 0b0011_1111 }, new byte[] { 0b1111_1111 }, 6 }; + yield return new object[] { new byte[] { 0b1000_0000 }, new byte[] { 0b0111_1111 }, new byte[] { 0b1111_1111 }, 7 }; - yield return new object[] {new byte[] {0b0000_0000}, new byte[] {0b0000_1111, 0b1111_0000}, new byte[] {0b1111_1111}, 12}; - yield return new object[] {new byte[] {0b0000_0000}, new byte[] {0b0111_1111, 0b1000_0000}, new byte[] {0b1111_1111}, 15}; + yield return new object[] { new byte[] { 0b0000_0000 }, new byte[] { 0b0000_1111, 0b1111_0000 }, new byte[] { 0b1111_1111 }, 12 }; + yield return new object[] { new byte[] { 0b0000_0000 }, new byte[] { 0b0111_1111, 0b1000_0000 }, new byte[] { 0b1111_1111 }, 15 }; - yield return new object[] {new byte[] {0b1110_0000, 0b0000_0000}, new byte[] {0b00001_1111, 0b1111_1111}, new byte[] {0b1111_1111, 0b1111_1111}, 13}; + yield return new object[] { new byte[] { 0b1110_0000, 0b0000_0000 }, new byte[] { 0b00001_1111, 0b1111_1111 }, new byte[] { 0b1111_1111, 0b1111_1111 }, 13 }; - yield return new object[] {new byte[] {0b1100_0000}, new byte[] {0b0000_0101}, new byte[] {0b101_1100}, 4}; - yield return new object[] {new byte[] {0b1100_1100, 0b0011_0000}, new byte[] {0b0000_0101}, new byte[] {0b0101_1100, 0b1100_0011}, 4}; - yield return new object[] {new byte[] {0b1000_0000, 0b0000_0000}, new byte[] {0b0110_1110, 0b0110_0001}, new byte[] {0b01101_1100, 0b1100_0011}, 15}; + yield return new object[] { new byte[] { 0b1100_0000 }, new byte[] { 0b0000_0101 }, new byte[] { 0b101_1100 }, 4 }; + yield return new object[] { new byte[] { 0b1100_1100, 0b0011_0000 }, new byte[] { 0b0000_0101 }, new byte[] { 0b0101_1100, 0b1100_0011 }, 4 }; + yield return new object[] { new byte[] { 0b1000_0000, 0b0000_0000 }, new byte[] { 0b0110_1110, 0b0110_0001 }, new byte[] { 0b01101_1100, 0b1100_0011 }, 15 }; // ragged far shift - yield return new object[] {new byte[] {0x00}, new byte[] {0x7F, 0x80, 0x00, 0x00}, new byte[] {0xFF}, 31}; + yield return new object[] { new byte[] { 0x00 }, new byte[] { 0x7F, 0x80, 0x00, 0x00 }, new byte[] { 0xFF }, 31 }; } [Theory] @@ -413,20 +413,20 @@ public void ShiftBitsLeft_Test(byte[] expected, public void ShiftBitsLeft_NullInput_ThrowsArgumentNullException_Test() { // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).ShiftBitsLeft(42, out _)); + Assert.Throws(() => ((byte[])null).ShiftBitsLeft(42, out _)); // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).ShiftBitsLeft(42)); + Assert.Throws(() => ((byte[])null).ShiftBitsLeft(42)); } [Fact] public void ShiftBitsLeft_ShiftLessThanZero_ThrowsArgumentOutOfRangeException_Test() { // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => new byte[] {0x00}.ShiftBitsLeft(-1, out _)); + Assert.Throws(() => new byte[] { 0x00 }.ShiftBitsLeft(-1, out _)); // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => new byte[] {0x00}.ShiftBitsLeft(-1)); + Assert.Throws(() => new byte[] { 0x00 }.ShiftBitsLeft(-1)); } #endregion @@ -458,7 +458,7 @@ public void Reverse_Test(ulong input) public void Reverse_InputNull_ThrowsArgumentNullException_Test() { // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).ReverseBytes()); + Assert.Throws(() => ((byte[])null).ReverseBytes()); } #endregion @@ -480,7 +480,7 @@ public static IEnumerable AppendShortest_Test_Values() { var right = new byte[j]; rand.NextBytes(right); - yield return new object[] {left, right}; + yield return new object[] { left, right }; } } } @@ -544,8 +544,8 @@ public void AppendShortest_Test(byte[] left, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void AppendShortest_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -561,11 +561,11 @@ public void AppendShortest_NullInput_ThrowsArgumentNullException_Test(byte[] lef [Theory] [InlineData(new byte[] { }, 0, 0x00)] - [InlineData(new byte[] {0x01, 0x02}, 0, 0x00)] - [InlineData(new byte[] {0x01, 0x02}, 2, 0x00)] + [InlineData(new byte[] { 0x01, 0x02 }, 0, 0x00)] + [InlineData(new byte[] { 0x01, 0x02 }, 2, 0x00)] [InlineData(new byte[] { }, 0, 0xAC)] - [InlineData(new byte[] {0x34, 0x12}, 0, 0xAC)] - [InlineData(new byte[] {0x34, 0x12}, 2, 0xAC)] + [InlineData(new byte[] { 0x34, 0x12 }, 0, 0xAC)] + [InlineData(new byte[] { 0x34, 0x12 }, 2, 0xAC)] public void AppendBytes_Test(byte[] source, int count, byte element) @@ -599,7 +599,7 @@ public void AppendBytes_NullSource_ThrowsArgumentNullException_Test() public void AppendBytes_CountLessThan0_ThrowsArgumentOutOfRangeException_Test() { // Arrange - var source = new byte[] {0xFF, 0xFF}; + var source = new byte[] { 0xFF, 0xFF }; const int count = -1; // Act @@ -611,7 +611,7 @@ public void AppendBytes_CountLessThan0_ThrowsArgumentOutOfRangeException_Test() public void AppendBytes_DefaultsTo0x00_Test() { // Arrange - var source = new byte[] {0xFF, 0xFF}; + var source = new byte[] { 0xFF, 0xFF }; const int count = 4; // Act @@ -627,11 +627,11 @@ public void AppendBytes_DefaultsTo0x00_Test() [Theory] [InlineData(new byte[] { }, 0, 0x00)] - [InlineData(new byte[] {0x01, 0x02}, 0, 0x00)] - [InlineData(new byte[] {0x01, 0x02}, 2, 0x00)] + [InlineData(new byte[] { 0x01, 0x02 }, 0, 0x00)] + [InlineData(new byte[] { 0x01, 0x02 }, 2, 0x00)] [InlineData(new byte[] { }, 0, 0xAC)] - [InlineData(new byte[] {0x34, 0x12}, 0, 0xAC)] - [InlineData(new byte[] {0x34, 0x12}, 2, 0xAC)] + [InlineData(new byte[] { 0x34, 0x12 }, 0, 0xAC)] + [InlineData(new byte[] { 0x34, 0x12 }, 2, 0xAC)] public void PrependBytes_Test(byte[] source, int count, byte element) @@ -665,7 +665,7 @@ public void PrependBytes_NullSource_ThrowsArgumentNullException_Test() public void PrependBytes_CountLessThan0_ThrowsArgumentOutOfRangeException_Test() { // Arrange - var source = new byte[] {0xFF, 0xFF}; + var source = new byte[] { 0xFF, 0xFF }; const int count = -1; // Act @@ -677,7 +677,7 @@ public void PrependBytes_CountLessThan0_ThrowsArgumentOutOfRangeException_Test() public void PrependBytes_DefaultsTo0x00_Test() { // Arrange - var source = new byte[] {0xFF, 0xFF}; + var source = new byte[] { 0xFF, 0xFF }; const int count = 4; // Act @@ -706,7 +706,7 @@ public static IEnumerable PrependShortest_Test_Values() { var right = new byte[j]; rand.NextBytes(right); - yield return new object[] {left, right}; + yield return new object[] { left, right }; } } } @@ -770,8 +770,8 @@ public void PrependShortest_Test(byte[] left, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void PrependShortest_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { diff --git a/src/Gulliver.Tests/ByteArrayUtils_BigEndian_Tests.cs b/src/Gulliver.Tests/ByteArrayUtils_BigEndian_Tests.cs index 3670a63..4cc58dc 100644 --- a/src/Gulliver.Tests/ByteArrayUtils_BigEndian_Tests.cs +++ b/src/Gulliver.Tests/ByteArrayUtils_BigEndian_Tests.cs @@ -19,8 +19,8 @@ public partial class ByteArrayUtilsTests public static IEnumerable TrySumBigEndian_Test_Values() { - var deltas = new[] {long.MinValue, -255, -129, -127, -1, 0, 1, 127, 129, 255, long.MaxValue}; - var uints = new uint[] {uint.MinValue, 1, 127, 129, 255, uint.MaxValue}; + var deltas = new[] { long.MinValue, -255, -129, -127, -1, 0, 1, 127, 129, 255, long.MaxValue }; + var uints = new uint[] { uint.MinValue, 1, 127, 129, 255, uint.MaxValue }; foreach (var delta in deltas) { @@ -39,7 +39,7 @@ public static IEnumerable TrySumBigEndian_Test_Values() if (delta < 0 && input - delta < 0) { - yield return new object[] {false, Array.Empty(), inputBytes, delta}; + yield return new object[] { false, Array.Empty(), inputBytes, delta }; yield break; } @@ -47,7 +47,7 @@ public static IEnumerable TrySumBigEndian_Test_Values() ? ByteArrayUtils.SubtractUnsignedBigEndian(inputBytes, deltaBytes) : ByteArrayUtils.AddUnsignedBigEndian(inputBytes, deltaBytes); - yield return new object[] {true, expectedBytes, inputBytes, delta}; + yield return new object[] { true, expectedBytes, inputBytes, delta }; } } } @@ -114,10 +114,10 @@ IEnumerable TestCases() var leftBytesTrimmed = leftBytes.TrimBigEndianLeadingZeroBytes(); var rightBytesTrimmed = rightBytes.TrimBigEndianLeadingZeroBytes(); - yield return new object[] {expected, leftBytes, rightBytes}; - yield return new object[] {expected, leftBytesTrimmed, rightBytes}; - yield return new object[] {expected, leftBytes, rightBytesTrimmed}; - yield return new object[] {expected, leftBytesTrimmed, rightBytesTrimmed}; + yield return new object[] { expected, leftBytes, rightBytes }; + yield return new object[] { expected, leftBytesTrimmed, rightBytes }; + yield return new object[] { expected, leftBytes, rightBytesTrimmed }; + yield return new object[] { expected, leftBytesTrimmed, rightBytesTrimmed }; } } } @@ -143,8 +143,8 @@ public void AddUnsignedBigEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void AddUnsignedBigEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -194,10 +194,10 @@ IEnumerable TestCases() var leftBytesTrimmed = leftBytes.TrimBigEndianLeadingZeroBytes(); var rightBytesTrimmed = rightBytes.TrimBigEndianLeadingZeroBytes(); - yield return new object[] {expected, leftBytes, rightBytes}; - yield return new object[] {expected, leftBytesTrimmed, rightBytes}; - yield return new object[] {expected, leftBytes, rightBytesTrimmed}; - yield return new object[] {expected, leftBytesTrimmed, rightBytesTrimmed}; + yield return new object[] { expected, leftBytes, rightBytes }; + yield return new object[] { expected, leftBytesTrimmed, rightBytes }; + yield return new object[] { expected, leftBytes, rightBytesTrimmed }; + yield return new object[] { expected, leftBytesTrimmed, rightBytesTrimmed }; } } } @@ -223,8 +223,8 @@ public void SubtractUnsignedBigEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void SubtractUnsignedBigEndian_NullInput_Throws_ArgumentNullException_Test(byte[] left, byte[] right) { @@ -238,8 +238,8 @@ public void SubtractUnsignedBigEndian_NullInput_Throws_ArgumentNullException_Tes public void SubtractUnsignedBigEndian_SignedOperation_Throws_InvalidOperationException_Test() { // Arrange - var left = new byte[] {0x00}; - var right = new byte[] {0x00, 0x0F}; + var left = new byte[] { 0x00 }; + var right = new byte[] { 0x00, 0x0F }; // Act // Assert @@ -281,10 +281,10 @@ IEnumerable TestCases() var expected = (left ?? 0).CompareTo(right ?? 0); - yield return new object[] {expected, leftBytes, rightBytes}; - yield return new object[] {expected, leftBytesTrimmed, rightBytes}; - yield return new object[] {expected, leftBytes, rightBytesTrimmed}; - yield return new object[] {expected, leftBytesTrimmed, rightBytesTrimmed}; + yield return new object[] { expected, leftBytes, rightBytes }; + yield return new object[] { expected, leftBytesTrimmed, rightBytes }; + yield return new object[] { expected, leftBytes, rightBytesTrimmed }; + yield return new object[] { expected, leftBytesTrimmed, rightBytesTrimmed }; } } } @@ -310,8 +310,8 @@ public void CompareUnsignedBigEndian_Test(int expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void CompareUnsignedBigEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -327,12 +327,12 @@ public void CompareUnsignedBigEndian_NullInput_ThrowsArgumentNullException_Test( [Theory] [InlineData(0, new byte[] { })] - [InlineData(1, new byte[] {0xff})] - [InlineData(1, new byte[] {0x00, 0xff})] - [InlineData(2, new byte[] {0x00, 0xff, 0xff})] - [InlineData(2, new byte[] {0xff, 0xff})] - [InlineData(3, new byte[] {0xff, 0xff, 0x00})] - [InlineData(3, new byte[] {0x00, 0xff, 0xff, 0x00})] + [InlineData(1, new byte[] { 0xff })] + [InlineData(1, new byte[] { 0x00, 0xff })] + [InlineData(2, new byte[] { 0x00, 0xff, 0xff })] + [InlineData(2, new byte[] { 0xff, 0xff })] + [InlineData(3, new byte[] { 0xff, 0xff, 0x00 })] + [InlineData(3, new byte[] { 0x00, 0xff, 0xff, 0x00 })] public void BigEndianEffectiveLength_Test(int expected, byte[] input) { @@ -352,7 +352,7 @@ public void BigEndianEffectiveLength_NullInput_ThrowsArgumentNullException_Test( // Act // Assert // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).BigEndianEffectiveLength()); + Assert.Throws(() => ((byte[])null).BigEndianEffectiveLength()); } #endregion @@ -452,8 +452,8 @@ public void BitwiseAndBigEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void BitwiseAndBigEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -558,8 +558,8 @@ public void BitwiseOrBigEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void BitwiseOrBigEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -664,8 +664,8 @@ public void BitwiseXorBigEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void BitwiseXorBigEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -689,37 +689,37 @@ public static IEnumerable TrimBigEndianLeadingZeros_Test_Values() var expected = Array.Empty(); var input = Enumerable.Range(0, i) - .Select(_ => (byte) 0x00) + .Select(_ => (byte)0x00) .Concat(expected.ToList()) .ToArray(); - yield return new object[] {expected, input}; + yield return new object[] { expected, input }; } // trim left for (var i = 0; i < 5; i++) { - var expected = new byte[] {0x0A, 0xF0}; + var expected = new byte[] { 0x0A, 0xF0 }; var input = Enumerable.Range(0, i) - .Select(_ => (byte) 0x00) + .Select(_ => (byte)0x00) .Concat(expected.ToList()) .ToArray(); - yield return new object[] {expected, input}; + yield return new object[] { expected, input }; } // don't trim right for (var i = 0; i < 5; i++) { - var expected = new byte[] {0x0A, 0xF0, 0x00}; + var expected = new byte[] { 0x0A, 0xF0, 0x00 }; var input = Enumerable.Range(0, i) - .Select(_ => (byte) 0x00) + .Select(_ => (byte)0x00) .Concat(expected.ToList()) .ToArray(); - yield return new object[] {expected, input}; + yield return new object[] { expected, input }; } } @@ -743,7 +743,7 @@ public void TrimBigEndianLeadingZeros_Test(byte[] expected, public void TrimBigEndianLeadingZeros_NullInput_ThrowsArgumentNullException_Test() { // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).TrimBigEndianLeadingZeroBytes()); + Assert.Throws(() => ((byte[])null).TrimBigEndianLeadingZeroBytes()); } #endregion @@ -753,25 +753,25 @@ public void TrimBigEndianLeadingZeros_NullInput_ThrowsArgumentNullException_Test public static IEnumerable PadBigEndianMostSignificantBytes_Test_Vales() { // no padding, not padded - yield return new object[] { Array.Empty(), Array.Empty(), 0, 0x00}; - yield return new object[] {new byte[] {0xfc}, new byte[] {0xfc}, 0, 0x00}; + yield return new object[] { Array.Empty(), Array.Empty(), 0, 0x00 }; + yield return new object[] { new byte[] { 0xfc }, new byte[] { 0xfc }, 0, 0x00 }; // input length equal to final length, not padded - yield return new object[] {new byte[] {0x00, 0x00}, new byte[] {0x00, 0x00}, 2, 0x00}; - yield return new object[] {new byte[] {0x00, 0x00}, new byte[] {0x00, 0x00}, 2, 0xfc}; + yield return new object[] { new byte[] { 0x00, 0x00 }, new byte[] { 0x00, 0x00 }, 2, 0x00 }; + yield return new object[] { new byte[] { 0x00, 0x00 }, new byte[] { 0x00, 0x00 }, 2, 0xfc }; // input length greater than final length, not padded - yield return new object[] {new byte[] {0x00, 0x00}, new byte[] {0x00, 0x00}, 1, 0x00}; - yield return new object[] {new byte[] {0xfc, 0xac}, new byte[] {0xfc, 0xac}, 1, 0xfc}; + yield return new object[] { new byte[] { 0x00, 0x00 }, new byte[] { 0x00, 0x00 }, 1, 0x00 }; + yield return new object[] { new byte[] { 0xfc, 0xac }, new byte[] { 0xfc, 0xac }, 1, 0xfc }; // empty input, padded - yield return new object[] {new byte[] {0x00, 0x00}, Array.Empty(), 2, 0x00}; - yield return new object[] {new byte[] {0xfc, 0xfc}, Array.Empty(), 2, 0xfc}; + yield return new object[] { new byte[] { 0x00, 0x00 }, Array.Empty(), 2, 0x00 }; + yield return new object[] { new byte[] { 0xfc, 0xfc }, Array.Empty(), 2, 0xfc }; // input length less than final length, padded - yield return new object[] {new byte[] {0x00, 0x00, 0x00, 0x00}, new byte[] {0x00, 0x00}, 4, 0x00}; - yield return new object[] {new byte[] {0xfc, 0xfc, 0x00, 0x00}, new byte[] {0x00, 0x00}, 4, 0xfc}; - yield return new object[] {new byte[] {0xfc, 0xfc, 0xac, 0xac}, new byte[] {0xac, 0xac}, 4, 0xfc}; + yield return new object[] { new byte[] { 0x00, 0x00, 0x00, 0x00 }, new byte[] { 0x00, 0x00 }, 4, 0x00 }; + yield return new object[] { new byte[] { 0xfc, 0xfc, 0x00, 0x00 }, new byte[] { 0x00, 0x00 }, 4, 0xfc }; + yield return new object[] { new byte[] { 0xfc, 0xfc, 0xac, 0xac }, new byte[] { 0xac, 0xac }, 4, 0xfc }; } [Theory] @@ -798,7 +798,7 @@ public void PadBigEndianMostSignificantBytes_NullSource_Throws_ArgumentNullExcep // Act // Assert // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).PadBigEndianMostSignificantBytes(42)); + Assert.Throws(() => ((byte[])null).PadBigEndianMostSignificantBytes(42)); } [Fact] diff --git a/src/Gulliver.Tests/ByteArrayUtils_Conversion_Tests.cs b/src/Gulliver.Tests/ByteArrayUtils_Conversion_Tests.cs index 6ba7c12..e4d1fa9 100644 --- a/src/Gulliver.Tests/ByteArrayUtils_Conversion_Tests.cs +++ b/src/Gulliver.Tests/ByteArrayUtils_Conversion_Tests.cs @@ -10,9 +10,9 @@ public partial class ByteArrayUtilsTests [Theory] [InlineData("", null)] [InlineData("", new byte[] { })] - [InlineData("00000000", new byte[] {0x00})] - [InlineData("00001111", new byte[] {0x0F})] - [InlineData("1010110011001010", new byte[] {0xAC, 0xCA})] + [InlineData("00000000", new byte[] { 0x00 })] + [InlineData("00001111", new byte[] { 0x0F })] + [InlineData("1010110011001010", new byte[] { 0xAC, 0xCA })] public void ToString_Binary_Contiguous_Test(string expected, byte[] input) { @@ -26,9 +26,9 @@ public void ToString_Binary_Contiguous_Test(string expected, [Theory] [InlineData("", null)] [InlineData("", new byte[] { })] - [InlineData("00000000", new byte[] {0x00})] - [InlineData("00001111", new byte[] {0x0F})] - [InlineData("10101100 11001010", new byte[] {0xAC, 0xCA})] + [InlineData("00000000", new byte[] { 0x00 })] + [InlineData("00001111", new byte[] { 0x0F })] + [InlineData("10101100 11001010", new byte[] { 0xAC, 0xCA })] public void ToString_Binary_Test(string expected, byte[] input) { @@ -42,9 +42,9 @@ public void ToString_Binary_Test(string expected, [Theory] [InlineData("", null)] [InlineData("", new byte[] { })] - [InlineData("000", new byte[] {0x00})] - [InlineData("015", new byte[] {0x0F})] - [InlineData("172 202", new byte[] {0xAC, 0xCA})] + [InlineData("000", new byte[] { 0x00 })] + [InlineData("015", new byte[] { 0x0F })] + [InlineData("172 202", new byte[] { 0xAC, 0xCA })] public void ToString_Decimal_Test(string expected, byte[] input) { @@ -58,9 +58,9 @@ public void ToString_Decimal_Test(string expected, [Theory] [InlineData("", null)] [InlineData("0", new byte[] { })] - [InlineData("0", new byte[] {0x00})] - [InlineData("15", new byte[] {0x0F})] - [InlineData("44234", new byte[] {0xAC, 0xCA})] + [InlineData("0", new byte[] { 0x00 })] + [InlineData("15", new byte[] { 0x0F })] + [InlineData("44234", new byte[] { 0xAC, 0xCA })] public void ToString_IntegerBigEndian_Test(string expected, byte[] input) { @@ -74,9 +74,9 @@ public void ToString_IntegerBigEndian_Test(string expected, [Theory] [InlineData("", null)] [InlineData("0", new byte[] { })] - [InlineData("0", new byte[] {0x00})] - [InlineData("15", new byte[] {0x0F})] - [InlineData("51884", new byte[] {0xAC, 0xCA})] + [InlineData("0", new byte[] { 0x00 })] + [InlineData("15", new byte[] { 0x0F })] + [InlineData("51884", new byte[] { 0xAC, 0xCA })] public void ToString_IntegerLittleEndian_Test(string expected, byte[] input) { @@ -89,9 +89,9 @@ public void ToString_IntegerLittleEndian_Test(string expected, [Theory] [InlineData("", null)] [InlineData("", new byte[] { })] - [InlineData("00", new byte[] {0x00})] - [InlineData("0f", new byte[] {0x0F})] - [InlineData("acca", new byte[] {0xAC, 0xCA})] + [InlineData("00", new byte[] { 0x00 })] + [InlineData("0f", new byte[] { 0x0F })] + [InlineData("acca", new byte[] { 0xAC, 0xCA })] public void ToString_LowerHexadecimal_Contiguous_Test(string expected, byte[] input) { @@ -104,9 +104,9 @@ public void ToString_LowerHexadecimal_Contiguous_Test(string expected, [Theory] [InlineData("", null)] [InlineData("", new byte[] { })] - [InlineData("00", new byte[] {0x00})] - [InlineData("0f", new byte[] {0x0F})] - [InlineData("ac ca", new byte[] {0xAC, 0xCA})] + [InlineData("00", new byte[] { 0x00 })] + [InlineData("0f", new byte[] { 0x0F })] + [InlineData("ac ca", new byte[] { 0xAC, 0xCA })] public void ToString_LowerHexadecimal_Test(string expected, byte[] input) { @@ -119,9 +119,9 @@ public void ToString_LowerHexadecimal_Test(string expected, [Theory] [InlineData("", null)] [InlineData("", new byte[] { })] - [InlineData("000", new byte[] {0x00})] - [InlineData("017", new byte[] {0x0F})] - [InlineData("254 312", new byte[] {0xAC, 0xCA})] + [InlineData("000", new byte[] { 0x00 })] + [InlineData("017", new byte[] { 0x0F })] + [InlineData("254 312", new byte[] { 0xAC, 0xCA })] public void ToString_Octal_Test(string expected, byte[] input) { @@ -135,9 +135,9 @@ public void ToString_Octal_Test(string expected, [Theory] [InlineData("", null)] [InlineData("", new byte[] { })] - [InlineData("00", new byte[] {0x00})] - [InlineData("0F", new byte[] {0x0F})] - [InlineData("ACCA", new byte[] {0xAC, 0xCA})] + [InlineData("00", new byte[] { 0x00 })] + [InlineData("0F", new byte[] { 0x0F })] + [InlineData("ACCA", new byte[] { 0xAC, 0xCA })] public void ToString_UpperHexadecimal_Contiguous_Test(string expected, byte[] input) { @@ -150,9 +150,9 @@ public void ToString_UpperHexadecimal_Contiguous_Test(string expected, [Theory] [InlineData("", null)] [InlineData("", new byte[] { })] - [InlineData("00", new byte[] {0x00})] - [InlineData("0F", new byte[] {0x0F})] - [InlineData("AC CA", new byte[] {0xAC, 0xCA})] + [InlineData("00", new byte[] { 0x00 })] + [InlineData("0F", new byte[] { 0x0F })] + [InlineData("AC CA", new byte[] { 0xAC, 0xCA })] public void ToString_UpperHexadecimal_Test(string expected, byte[] input) { diff --git a/src/Gulliver.Tests/ByteArrayUtils_LittleEndian_Tests.cs b/src/Gulliver.Tests/ByteArrayUtils_LittleEndian_Tests.cs index eff0b1a..ec85a76 100644 --- a/src/Gulliver.Tests/ByteArrayUtils_LittleEndian_Tests.cs +++ b/src/Gulliver.Tests/ByteArrayUtils_LittleEndian_Tests.cs @@ -19,8 +19,8 @@ public partial class ByteArrayUtilsTests public static IEnumerable TrySumLittleEndian_Test_Values() { - var deltas = new[] {long.MinValue, -255, -129, -127, -1, 0, 1, 127, 129, 255, long.MaxValue}; - var uints = new uint[] {uint.MinValue, 1, 127, 129, 255, uint.MaxValue}; + var deltas = new[] { long.MinValue, -255, -129, -127, -1, 0, 1, 127, 129, 255, long.MaxValue }; + var uints = new uint[] { uint.MinValue, 1, 127, 129, 255, uint.MaxValue }; foreach (var delta in deltas) { @@ -39,7 +39,7 @@ public static IEnumerable TrySumLittleEndian_Test_Values() if (delta < 0 && input - delta < 0) { - yield return new object[] {false, Array.Empty(), inputBytes, delta}; + yield return new object[] { false, Array.Empty(), inputBytes, delta }; yield break; } @@ -47,7 +47,7 @@ public static IEnumerable TrySumLittleEndian_Test_Values() ? ByteArrayUtils.SubtractUnsignedLittleEndian(inputBytes, deltaBytes) : ByteArrayUtils.AddUnsignedLittleEndian(inputBytes, deltaBytes); - yield return new object[] {true, expectedBytes, inputBytes, delta}; + yield return new object[] { true, expectedBytes, inputBytes, delta }; } } } @@ -114,10 +114,10 @@ IEnumerable TestCases() var leftBytesTrimmed = leftBytes.TrimLittleEndianLeadingZeroBytes(); var rightBytesTrimmed = rightBytes.TrimLittleEndianLeadingZeroBytes(); - yield return new object[] {expected, leftBytes, rightBytes}; - yield return new object[] {expected, leftBytesTrimmed, rightBytes}; - yield return new object[] {expected, leftBytes, rightBytesTrimmed}; - yield return new object[] {expected, leftBytesTrimmed, rightBytesTrimmed}; + yield return new object[] { expected, leftBytes, rightBytes }; + yield return new object[] { expected, leftBytesTrimmed, rightBytes }; + yield return new object[] { expected, leftBytes, rightBytesTrimmed }; + yield return new object[] { expected, leftBytesTrimmed, rightBytesTrimmed }; } } } @@ -143,8 +143,8 @@ public void AddUnsignedLittleEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void AddUnsignedLittleEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -194,10 +194,10 @@ IEnumerable TestCases() var leftBytesTrimmed = leftBytes.TrimLittleEndianLeadingZeroBytes(); var rightBytesTrimmed = rightBytes.TrimLittleEndianLeadingZeroBytes(); - yield return new object[] {expected, leftBytes, rightBytes}; - yield return new object[] {expected, leftBytesTrimmed, rightBytes}; - yield return new object[] {expected, leftBytes, rightBytesTrimmed}; - yield return new object[] {expected, leftBytesTrimmed, rightBytesTrimmed}; + yield return new object[] { expected, leftBytes, rightBytes }; + yield return new object[] { expected, leftBytesTrimmed, rightBytes }; + yield return new object[] { expected, leftBytes, rightBytesTrimmed }; + yield return new object[] { expected, leftBytesTrimmed, rightBytesTrimmed }; } } } @@ -223,8 +223,8 @@ public void SubtractUnsignedLittleEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void SubtractUnsignedLittleEndian_NullInput_Throws_ArgumentNullException_Test(byte[] left, byte[] right) { @@ -238,8 +238,8 @@ public void SubtractUnsignedLittleEndian_NullInput_Throws_ArgumentNullException_ public void SubtractUnsignedLittleEndian_SignedOperation_Throws_InvalidOperationException_Test() { // Arrange - var left = new byte[] {0x00}; - var right = new byte[] {0x00, 0x0F}; + var left = new byte[] { 0x00 }; + var right = new byte[] { 0x00, 0x0F }; // Act // Assert @@ -281,10 +281,10 @@ IEnumerable TestCases() var expected = (left ?? 0).CompareTo(right ?? 0); - yield return new object[] {expected, leftBytes, rightBytes}; - yield return new object[] {expected, leftBytesTrimmed, rightBytes}; - yield return new object[] {expected, leftBytes, rightBytesTrimmed}; - yield return new object[] {expected, leftBytesTrimmed, rightBytesTrimmed}; + yield return new object[] { expected, leftBytes, rightBytes }; + yield return new object[] { expected, leftBytesTrimmed, rightBytes }; + yield return new object[] { expected, leftBytes, rightBytesTrimmed }; + yield return new object[] { expected, leftBytesTrimmed, rightBytesTrimmed }; } } } @@ -314,8 +314,8 @@ public void CompareUnsignedLittleEndian_Test(int expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void CompareUnsignedLittleEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -331,12 +331,12 @@ public void CompareUnsignedLittleEndian_NullInput_ThrowsArgumentNullException_Te [Theory] [InlineData(0, new byte[] { })] - [InlineData(1, new byte[] {0xff})] - [InlineData(1, new byte[] {0xff, 0x00})] - [InlineData(2, new byte[] {0xff, 0xff, 0x00})] - [InlineData(2, new byte[] {0xff, 0xff})] - [InlineData(3, new byte[] {0x00, 0xff, 0xff})] - [InlineData(3, new byte[] {0x00, 0xff, 0xff, 0x00})] + [InlineData(1, new byte[] { 0xff })] + [InlineData(1, new byte[] { 0xff, 0x00 })] + [InlineData(2, new byte[] { 0xff, 0xff, 0x00 })] + [InlineData(2, new byte[] { 0xff, 0xff })] + [InlineData(3, new byte[] { 0x00, 0xff, 0xff })] + [InlineData(3, new byte[] { 0x00, 0xff, 0xff, 0x00 })] public void LittleEndianEffectiveLength_Test(int expected, byte[] input) { @@ -356,7 +356,7 @@ public void LittleEndianEffectiveLength_NullInput_ThrowsArgumentNullException_Te // Act // Assert // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).LittleEndianEffectiveLength()); + Assert.Throws(() => ((byte[])null).LittleEndianEffectiveLength()); } #endregion @@ -448,8 +448,8 @@ public void BitwiseAndLittleEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void BitwiseAndLittleEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -546,8 +546,8 @@ public void BitwiseOrLittleEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void BitwiseOrLittleEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -644,8 +644,8 @@ public void BitwiseXorLittleEndian_Test(byte[] expected, } [Theory] - [InlineData(null, new byte[] {0x00})] - [InlineData(new byte[] {0x00}, null)] + [InlineData(null, new byte[] { 0x00 })] + [InlineData(new byte[] { 0x00 }, null)] public void BitwiseXorLittleEndian_NullInput_ThrowsArgumentNullException_Test(byte[] left, byte[] right) { @@ -669,37 +669,37 @@ public static IEnumerable TrimLittleEndianLeadingZeros_Test_Values() var expected = Array.Empty(); var input = Enumerable.Range(0, i) - .Select(_ => (byte) 0x00) + .Select(_ => (byte)0x00) .Concat(expected.ToList()) .ToArray(); - yield return new object[] {expected, input}; + yield return new object[] { expected, input }; } // don't trim left for (var i = 0; i < 5; i++) { - var expected = new byte[] {0x00, 0x0A, 0xF0}; + var expected = new byte[] { 0x00, 0x0A, 0xF0 }; var input = expected .Concat(Enumerable.Range(0, i) - .Select(_ => (byte) 0x00)) + .Select(_ => (byte)0x00)) .ToArray(); - yield return new object[] {expected, input}; + yield return new object[] { expected, input }; } // trim right for (var i = 0; i < 5; i++) { - var expected = new byte[] {0x0A, 0xF0}; + var expected = new byte[] { 0x0A, 0xF0 }; var input = expected .Concat(Enumerable.Range(0, i) - .Select(_ => (byte) 0x00)) + .Select(_ => (byte)0x00)) .ToArray(); - yield return new object[] {expected, input}; + yield return new object[] { expected, input }; } } @@ -723,7 +723,7 @@ public void TrimLittleEndianLeadingZeros_Test(byte[] expected, public void TrimLittleEndianLeadingZeros_NullInput_ThrowsArgumentNullException_Test() { // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).TrimLittleEndianLeadingZeroBytes()); + Assert.Throws(() => ((byte[])null).TrimLittleEndianLeadingZeroBytes()); } #endregion @@ -733,25 +733,25 @@ public void TrimLittleEndianLeadingZeros_NullInput_ThrowsArgumentNullException_T public static IEnumerable PadLittleEndianMostSignificantBytes_Test_Vales() { // no padding, not padded - yield return new object[] { Array.Empty(), Array.Empty(), 0, 0x00}; - yield return new object[] {new byte[] {0xfc}, new byte[] {0xfc}, 0, 0x00}; + yield return new object[] { Array.Empty(), Array.Empty(), 0, 0x00 }; + yield return new object[] { new byte[] { 0xfc }, new byte[] { 0xfc }, 0, 0x00 }; // input length equal to final length, not padded - yield return new object[] {new byte[] {0x00, 0x00}, new byte[] {0x00, 0x00}, 2, 0x00}; - yield return new object[] {new byte[] {0x00, 0x00}, new byte[] {0x00, 0x00}, 2, 0xfc}; + yield return new object[] { new byte[] { 0x00, 0x00 }, new byte[] { 0x00, 0x00 }, 2, 0x00 }; + yield return new object[] { new byte[] { 0x00, 0x00 }, new byte[] { 0x00, 0x00 }, 2, 0xfc }; // input length greater than final length, not padded - yield return new object[] {new byte[] {0x00, 0x00}, new byte[] {0x00, 0x00}, 1, 0x00}; - yield return new object[] {new byte[] {0xfc, 0xac}, new byte[] {0xfc, 0xac}, 1, 0xfc}; + yield return new object[] { new byte[] { 0x00, 0x00 }, new byte[] { 0x00, 0x00 }, 1, 0x00 }; + yield return new object[] { new byte[] { 0xfc, 0xac }, new byte[] { 0xfc, 0xac }, 1, 0xfc }; // empty input, padded - yield return new object[] {new byte[] {0x00, 0x00}, Array.Empty(), 2, 0x00}; - yield return new object[] {new byte[] {0xfc, 0xfc}, Array.Empty(), 2, 0xfc}; + yield return new object[] { new byte[] { 0x00, 0x00 }, Array.Empty(), 2, 0x00 }; + yield return new object[] { new byte[] { 0xfc, 0xfc }, Array.Empty(), 2, 0xfc }; // input length less than final length, padded - yield return new object[] {new byte[] {0x00, 0x00, 0x00, 0x00}, new byte[] {0x00, 0x00}, 4, 0x00}; - yield return new object[] {new byte[] {0x00, 0x00, 0xfc, 0xfc}, new byte[] {0x00, 0x00}, 4, 0xfc}; - yield return new object[] {new byte[] {0xac, 0xac, 0xfc, 0xfc}, new byte[] {0xac, 0xac}, 4, 0xfc}; + yield return new object[] { new byte[] { 0x00, 0x00, 0x00, 0x00 }, new byte[] { 0x00, 0x00 }, 4, 0x00 }; + yield return new object[] { new byte[] { 0x00, 0x00, 0xfc, 0xfc }, new byte[] { 0x00, 0x00 }, 4, 0xfc }; + yield return new object[] { new byte[] { 0xac, 0xac, 0xfc, 0xfc }, new byte[] { 0xac, 0xac }, 4, 0xfc }; } [Theory] @@ -778,7 +778,7 @@ public void PadLittleEndianMostSignificantBytes_NullSource_Throws_ArgumentNullEx // Act // Assert // ReSharper disable once AssignNullToNotNullAttribute - Assert.Throws(() => ((byte[]) null).PadLittleEndianMostSignificantBytes(42)); + Assert.Throws(() => ((byte[])null).PadLittleEndianMostSignificantBytes(42)); } [Fact] diff --git a/src/Gulliver.Tests/Enumerables/BigEndianByteEnumerableTests.cs b/src/Gulliver.Tests/Enumerables/BigEndianByteEnumerableTests.cs index 9d5ad1a..017d3e2 100644 --- a/src/Gulliver.Tests/Enumerables/BigEndianByteEnumerableTests.cs +++ b/src/Gulliver.Tests/Enumerables/BigEndianByteEnumerableTests.cs @@ -77,7 +77,7 @@ public void Ctor_Trim_Set_Test(bool trim) public void Iteration_Trimmed_Test() { // Arrange - var input = new byte[] {0x00, 0x00, 0xAC, 0xCA, 0x00}; + var input = new byte[] { 0x00, 0x00, 0xAC, 0xCA, 0x00 }; var expected = input.SkipWhile(b => b == 0x00); var enumerable = new BigEndianByteEnumerable(input); @@ -91,7 +91,7 @@ public void Iteration_Trimmed_Test() public void Iteration_Untrimmed_Test() { // Arrange - var input = new byte[] {0x00, 0x00, 0xAC, 0xCA, 0x00}; + var input = new byte[] { 0x00, 0x00, 0xAC, 0xCA, 0x00 }; var expected = input; var enumerable = new BigEndianByteEnumerable(input, false); @@ -109,7 +109,7 @@ public void Iteration_Untrimmed_Test() public void ReverseIteration_Trimmed_Test() { // Arrange - var input = new byte[] {0x00, 0x00, 0xAC, 0xCA, 0x00}; + var input = new byte[] { 0x00, 0x00, 0xAC, 0xCA, 0x00 }; var expected = input.SkipWhile(b => b == 0x00) .Reverse(); @@ -128,7 +128,7 @@ public void ReverseIteration_Trimmed_Test() public void ReverseIteration_Untrimmed_Test() { // Arrange - var input = new byte[] {0x00, 0x00, 0xAC, 0xCA, 0x00}; + var input = new byte[] { 0x00, 0x00, 0xAC, 0xCA, 0x00 }; var expected = input.Reverse(); var enumerable = new BigEndianByteEnumerable(input, false); @@ -154,7 +154,7 @@ public void ReverseIteration_Untrimmed_Test() public void Enumerate_Trimmed_Test() { // Arrange - var input = new byte[] {0x00, 0x00, 0xAC, 0xCA, 0x00}; + var input = new byte[] { 0x00, 0x00, 0xAC, 0xCA, 0x00 }; var expected = input.SkipWhile(b => b == 0x00); var enumerable = new BigEndianByteEnumerable(input); @@ -174,7 +174,7 @@ public void Enumerate_Trimmed_Test() public void Enumerate_Untrimmed_Test() { // Arrange - var input = new byte[] {0x00, 0x00, 0xAC, 0xCA, 0x00}; + var input = new byte[] { 0x00, 0x00, 0xAC, 0xCA, 0x00 }; var expected = input; var enumerable = new BigEndianByteEnumerable(input, false); @@ -200,7 +200,7 @@ public void Enumerate_Untrimmed_Test() public void ReverseEnumeration_Trimmed_Test() { // Arrange - var input = new byte[] {0x00, 0x00, 0xAC, 0xCA, 0x00}; + var input = new byte[] { 0x00, 0x00, 0xAC, 0xCA, 0x00 }; var expected = input.SkipWhile(b => b == 0x00) .Reverse(); @@ -219,7 +219,7 @@ public void ReverseEnumeration_Trimmed_Test() public void ReverseEnumeration_Untrimmed_Test() { // Arrange - var input = new byte[] {0x00, 0x00, 0xAC, 0xCA, 0x00}; + var input = new byte[] { 0x00, 0x00, 0xAC, 0xCA, 0x00 }; var expected = input.Reverse(); var enumerable = new BigEndianByteEnumerable(input, false); diff --git a/src/Gulliver.Tests/Enumerables/ConcurrentBigEndianByteEnumerableTests.cs b/src/Gulliver.Tests/Enumerables/ConcurrentBigEndianByteEnumerableTests.cs index 8655b77..ef4d308 100644 --- a/src/Gulliver.Tests/Enumerables/ConcurrentBigEndianByteEnumerableTests.cs +++ b/src/Gulliver.Tests/Enumerables/ConcurrentBigEndianByteEnumerableTests.cs @@ -46,7 +46,7 @@ public static IEnumerable Byte_Values() { foreach (var right in byteValues) { - yield return new object[] {left, right}; + yield return new object[] { left, right }; } } @@ -144,11 +144,11 @@ public void Iterate_FromByteEnumerable_Trimmed_Test(byte[] leftBytes, var length = Math.Max(expectedTrimmedLeftLength, expectedTrimmedRightLength); this._testOutputHelper.WriteLine($"expectedLength: {length}"); - var expectedLeft = Enumerable.Repeat((byte) 0x00, length - expectedTrimmedLeftLength) + var expectedLeft = Enumerable.Repeat((byte)0x00, length - expectedTrimmedLeftLength) .Concat(leftBytes.Skip(leftBytes.Length - expectedTrimmedLeftLength)) .ToArray(); - var expectedRight = Enumerable.Repeat((byte) 0x00, length - expectedTrimmedRightLength) + var expectedRight = Enumerable.Repeat((byte)0x00, length - expectedTrimmedRightLength) .Concat(rightBytes.Skip(rightBytes.Length - expectedTrimmedRightLength)) .ToArray(); @@ -192,11 +192,11 @@ public void Iterate_FromByteEnumerable_NonTrimmed_Test(byte[] leftBytes, this._testOutputHelper.WriteLine($"expectedLength: {length}"); - var expectedLeft = Enumerable.Repeat((byte) 0x00, length - leftBytes.Length) + var expectedLeft = Enumerable.Repeat((byte)0x00, length - leftBytes.Length) .Concat(leftBytes) .ToArray(); - var expectedRight = Enumerable.Repeat((byte) 0x00, length - rightBytes.Length) + var expectedRight = Enumerable.Repeat((byte)0x00, length - rightBytes.Length) .Concat(rightBytes) .ToArray(); @@ -243,12 +243,12 @@ public void ReverseIterate_FromByteEnumerable_Trimmed_Test(byte[] leftBytes, var length = Math.Max(expectedTrimmedLeftLength, expectedTrimmedRightLength); this._testOutputHelper.WriteLine($"expectedLength: {length}"); - var expectedLeft = Enumerable.Repeat((byte) 0x00, length - expectedTrimmedLeftLength) + var expectedLeft = Enumerable.Repeat((byte)0x00, length - expectedTrimmedLeftLength) .Concat(leftBytes.Skip(leftBytes.Length - expectedTrimmedLeftLength)) .Reverse() .ToArray(); - var expectedRight = Enumerable.Repeat((byte) 0x00, length - expectedTrimmedRightLength) + var expectedRight = Enumerable.Repeat((byte)0x00, length - expectedTrimmedRightLength) .Concat(rightBytes.Skip(rightBytes.Length - expectedTrimmedRightLength)) .Reverse() .ToArray(); @@ -294,12 +294,12 @@ public void ReverseIterate_FromByteEnumerable_NonTrimmed_Test(byte[] leftBytes, this._testOutputHelper.WriteLine($"expectedLength: {length}"); - var expectedLeft = Enumerable.Repeat((byte) 0x00, length - leftBytes.Length) + var expectedLeft = Enumerable.Repeat((byte)0x00, length - leftBytes.Length) .Concat(leftBytes) .Reverse() .ToArray(); - var expectedRight = Enumerable.Repeat((byte) 0x00, length - rightBytes.Length) + var expectedRight = Enumerable.Repeat((byte)0x00, length - rightBytes.Length) .Concat(rightBytes) .Reverse() .ToArray(); diff --git a/src/Gulliver.Tests/Enumerables/ConcurrentLittleEndianByteEnumerableTests.cs b/src/Gulliver.Tests/Enumerables/ConcurrentLittleEndianByteEnumerableTests.cs index e383b86..9456b2f 100644 --- a/src/Gulliver.Tests/Enumerables/ConcurrentLittleEndianByteEnumerableTests.cs +++ b/src/Gulliver.Tests/Enumerables/ConcurrentLittleEndianByteEnumerableTests.cs @@ -46,7 +46,7 @@ public static IEnumerable Byte_Values() { foreach (var right in byteValues) { - yield return new object[] {left, right}; + yield return new object[] { left, right }; } } @@ -87,11 +87,11 @@ public void Iterate_FromByteEnumerable_Trimmed_Test(byte[] leftBytes, this._testOutputHelper.WriteLine($"expectedLength: {length}"); var expectedLeft = leftBytes.Take(expectedTrimmedLeftLength) - .Concat(Enumerable.Repeat((byte) 0x00, length - expectedTrimmedLeftLength)) + .Concat(Enumerable.Repeat((byte)0x00, length - expectedTrimmedLeftLength)) .ToArray(); var expectedRight = rightBytes.Take(expectedTrimmedRightLength) - .Concat(Enumerable.Repeat((byte) 0x00, length - expectedTrimmedRightLength)) + .Concat(Enumerable.Repeat((byte)0x00, length - expectedTrimmedRightLength)) .ToArray(); this._testOutputHelper.WriteLine($"expected left: [{expectedLeft.ToString("h")}]"); @@ -134,10 +134,10 @@ public void Iterate_FromByteEnumerable_NonTrimmed_Test(byte[] leftBytes, this._testOutputHelper.WriteLine($"expectedLength: {length}"); - var expectedLeft = leftBytes.Concat(Enumerable.Repeat((byte) 0x00, length - leftBytes.Length)) + var expectedLeft = leftBytes.Concat(Enumerable.Repeat((byte)0x00, length - leftBytes.Length)) .ToArray(); - var expectedRight = rightBytes.Concat(Enumerable.Repeat((byte) 0x00, length - rightBytes.Length)) + var expectedRight = rightBytes.Concat(Enumerable.Repeat((byte)0x00, length - rightBytes.Length)) .ToArray(); this._testOutputHelper.WriteLine($"expected left: [{expectedLeft.ToString("h")}]"); @@ -186,12 +186,12 @@ public void ReverseIterate_FromByteEnumerable_Trimmed_Test(byte[] leftBytes, this._testOutputHelper.WriteLine($"expectedLength: {length}"); var expectedLeft = leftBytes.Take(expectedTrimmedLeftLength) - .Concat(Enumerable.Repeat((byte) 0x00, length - expectedTrimmedLeftLength)) + .Concat(Enumerable.Repeat((byte)0x00, length - expectedTrimmedLeftLength)) .Reverse() .ToArray(); var expectedRight = rightBytes.Take(expectedTrimmedRightLength) - .Concat(Enumerable.Repeat((byte) 0x00, length - expectedTrimmedRightLength)) + .Concat(Enumerable.Repeat((byte)0x00, length - expectedTrimmedRightLength)) .Reverse() .ToArray(); @@ -236,11 +236,11 @@ public void ReverseIterate_FromByteEnumerable_NonTrimmed_Test(byte[] leftBytes, this._testOutputHelper.WriteLine($"expectedLength: {length}"); - var expectedLeft = leftBytes.Concat(Enumerable.Repeat((byte) 0x00, length - leftBytes.Length)) + var expectedLeft = leftBytes.Concat(Enumerable.Repeat((byte)0x00, length - leftBytes.Length)) .Reverse() .ToArray(); - var expectedRight = rightBytes.Concat(Enumerable.Repeat((byte) 0x00, length - rightBytes.Length)) + var expectedRight = rightBytes.Concat(Enumerable.Repeat((byte)0x00, length - rightBytes.Length)) .Reverse() .ToArray(); diff --git a/src/Gulliver.Tests/Enumerables/LittleEndianByteEnumerableTests.cs b/src/Gulliver.Tests/Enumerables/LittleEndianByteEnumerableTests.cs index 310d252..a7ce117 100644 --- a/src/Gulliver.Tests/Enumerables/LittleEndianByteEnumerableTests.cs +++ b/src/Gulliver.Tests/Enumerables/LittleEndianByteEnumerableTests.cs @@ -77,7 +77,7 @@ public void Ctor_Trim_Set_Test(bool trim) public void Iteration_Trimmed_Test() { // Arrange - var input = new byte[] {0x00, 0xAC, 0xCA, 0x00, 0x00}; + var input = new byte[] { 0x00, 0xAC, 0xCA, 0x00, 0x00 }; var expected = input.Reverse() .SkipWhile(b => b == 0x00) .Reverse(); @@ -93,7 +93,7 @@ public void Iteration_Trimmed_Test() public void Iteration_Untrimmed_Test() { // Arrange - var input = new byte[] {0x00, 0xAC, 0xCA, 0x00, 0x00}; + var input = new byte[] { 0x00, 0xAC, 0xCA, 0x00, 0x00 }; var expected = input; var enumerable = new LittleEndianByteEnumerable(input, false); @@ -111,7 +111,7 @@ public void Iteration_Untrimmed_Test() public void ReverseIteration_Trimmed_Test() { // Arrange - var input = new byte[] {0x00, 0xAC, 0xCA, 0x00, 0x00}; + var input = new byte[] { 0x00, 0xAC, 0xCA, 0x00, 0x00 }; var expected = input.Reverse() .SkipWhile(b => b == 0x00); @@ -130,7 +130,7 @@ public void ReverseIteration_Trimmed_Test() public void ReverseIteration_Untrimmed_Test() { // Arrange - var input = new byte[] {0x00, 0xAC, 0xCA, 0x00, 0x00}; + var input = new byte[] { 0x00, 0xAC, 0xCA, 0x00, 0x00 }; var expected = input.Reverse(); var enumerable = new LittleEndianByteEnumerable(input, false); @@ -156,7 +156,7 @@ public void ReverseIteration_Untrimmed_Test() public void Enumerate_Trimmed_Test() { // Arrange - var input = new byte[] {0x00, 0xAC, 0xCA, 0x00, 0x00}; + var input = new byte[] { 0x00, 0xAC, 0xCA, 0x00, 0x00 }; var expected = input.Reverse() .SkipWhile(b => b == 0x00) .Reverse(); @@ -178,7 +178,7 @@ public void Enumerate_Trimmed_Test() public void Enumerate_Untrimmed_Test() { // Arrange - var input = new byte[] {0x00, 0xAC, 0xCA, 0x00, 0x00}; + var input = new byte[] { 0x00, 0xAC, 0xCA, 0x00, 0x00 }; var expected = input; var enumerable = new LittleEndianByteEnumerable(input, false); @@ -204,7 +204,7 @@ public void Enumerate_Untrimmed_Test() public void ReverseEnumeration_Trimmed_Test() { // Arrange - var input = new byte[] {0x00, 0xAC, 0xCA, 0x00, 0x00}; + var input = new byte[] { 0x00, 0xAC, 0xCA, 0x00, 0x00 }; var expected = input.Reverse() .SkipWhile(b => b == 0x00); @@ -223,7 +223,7 @@ public void ReverseEnumeration_Trimmed_Test() public void ReverseEnumeration_Untrimmed_Test() { // Arrange - var input = new byte[] {0x00, 0xAC, 0xCA, 0x00, 0x00}; + var input = new byte[] { 0x00, 0xAC, 0xCA, 0x00, 0x00 }; var expected = input.Reverse(); var enumerable = new LittleEndianByteEnumerable(input, false); diff --git a/src/Gulliver.Tests/FixedBytesTests.cs b/src/Gulliver.Tests/FixedBytesTests.cs index c4514d3..b2c2b71 100644 --- a/src/Gulliver.Tests/FixedBytesTests.cs +++ b/src/Gulliver.Tests/FixedBytesTests.cs @@ -43,7 +43,7 @@ public void Assignability_Test() public void GetBytes_Test() { // Arrange - var bytes = new byte[] {0xAC, 0xCA}; + var bytes = new byte[] { 0xAC, 0xCA }; var fixedBytes = new FixedBytes(bytes); // Act @@ -63,7 +63,7 @@ public void GetBytes_Test() public void GetBytesLittleEndian_Test() { // Arrange - var bytes = new byte[] {0xAC, 0xCA}; + var bytes = new byte[] { 0xAC, 0xCA }; var fixedBytes = new FixedBytes(bytes); // Act @@ -88,7 +88,7 @@ public void GetBytesLittleEndian_Test() public void Construct_ProvidedBytesAtLength_Test() { // Arrange - var input = new byte[] {0xAC, 0x00, 0xCA}; + var input = new byte[] { 0xAC, 0x00, 0xCA }; // Act var fixedBytes = new FixedBytes(input, input.Length); @@ -117,7 +117,7 @@ public void Construct_NullBytes_Throws_ArgumentNullException_Test() public void Construct_LengthLessThanBytesLength_Throws_ArgumentException_Test() { // Arrange - var input = new byte[] {0xAC, 0x00, 0xCA}; + var input = new byte[] { 0xAC, 0x00, 0xCA }; // Act // Assert @@ -133,7 +133,7 @@ public void Construct_LengthLessThanBytesLength_Throws_ArgumentException_Test() public void Construct_LengthNegative_Throws_ArgumentException_Test() { // Arrange - var input = new byte[] {0xAC, 0x00, 0xCA}; + var input = new byte[] { 0xAC, 0x00, 0xCA }; // Act // Assert @@ -149,7 +149,7 @@ public void Construct_LengthNegative_Throws_ArgumentException_Test() public void Construct_ProvidedBytesShorterThanLength_Test() { // Arrange - var input = new byte[] {0xAC, 0x00, 0xCA}; + var input = new byte[] { 0xAC, 0x00, 0xCA }; const int length = 10; // Act @@ -158,7 +158,7 @@ public void Construct_ProvidedBytesShorterThanLength_Test() // Assert var bytes = fixedBytes.GetBytes(); Assert.Equal(length, bytes.Length); - Assert.Equal(Enumerable.Repeat((byte) 0x00, length - input.Length) + Assert.Equal(Enumerable.Repeat((byte)0x00, length - input.Length) .Concat(input), bytes); } @@ -189,17 +189,17 @@ public void Empty_Test() public static IEnumerable Equal_IEnumerableBytes_Test_Values() { // equality compare to null - yield return new object[] {false, new FixedBytes(Array.Empty()), null}; + yield return new object[] { false, new FixedBytes(Array.Empty()), null }; // equality compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {true, new FixedBytes(sameBytes), sameBytes}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { true, new FixedBytes(sameBytes), sameBytes }; // equality compare non-equal bytes by length - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new byte[] {0xFF, 0xFF}}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new byte[] { 0xFF, 0xFF } }; // equality compare non-equal bytes - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new byte[] {0xFF}}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new byte[] { 0xFF } }; } [Theory] @@ -223,17 +223,17 @@ public void Equal_IEnumerableBytes_Test(bool expected, public static IEnumerable Equal_FixedBytes_Test_Values() { // equality compare to null - yield return new object[] {false, new FixedBytes(Array.Empty()), null}; + yield return new object[] { false, new FixedBytes(Array.Empty()), null }; // equality compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {true, new FixedBytes(sameBytes), new FixedBytes(sameBytes)}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { true, new FixedBytes(sameBytes), new FixedBytes(sameBytes) }; // equality compare non-equal bytes by length - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0xFF, 0xFF})}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0xFF, 0xFF }) }; // equality compare non-equal bytes - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0xFF})}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0xFF }) }; } [Theory] @@ -263,20 +263,20 @@ public static IEnumerable Addition_Test_Values() foreach (var (left, right) in Values()) { var expected = new FixedBytes(ByteArrayUtils.AddUnsignedBigEndian(left, right)); - yield return new object[] {expected, new FixedBytes(left), new FixedBytes(right)}; + yield return new object[] { expected, new FixedBytes(left), new FixedBytes(right) }; } - yield return new object[] {null, null, new FixedBytes(new byte[] {0xFF})}; - yield return new object[] {null, new FixedBytes(new byte[] {0xFF}), null}; - yield return new object[] {null, null, null}; + yield return new object[] { null, null, new FixedBytes(new byte[] { 0xFF }) }; + yield return new object[] { null, new FixedBytes(new byte[] { 0xFF }), null }; + yield return new object[] { null, null, null }; IEnumerable<(byte[] left, byte[] right)> Values() { - yield return (new byte[] {0xFF}, Array.Empty()); - yield return (new byte[] {0x00}, new byte[] {0x00}); - yield return (new byte[] {0xF0}, new byte[] {0x0F}); - yield return (new byte[] {0x42}, new byte[] {0xBD}); - yield return (new byte[] {0xFF}, new byte[] {0xBD}); + yield return (new byte[] { 0xFF }, Array.Empty()); + yield return (new byte[] { 0x00 }, new byte[] { 0x00 }); + yield return (new byte[] { 0xF0 }, new byte[] { 0x0F }); + yield return (new byte[] { 0x42 }, new byte[] { 0xBD }); + yield return (new byte[] { 0xFF }, new byte[] { 0xBD }); } } @@ -302,22 +302,22 @@ public static IEnumerable Subtraction_Test_Values() foreach (var (left, right) in Values()) { var expected = new FixedBytes(ByteArrayUtils.SubtractUnsignedBigEndian(left, right)); - yield return new object[] {expected, new FixedBytes(left), new FixedBytes(right)}; + yield return new object[] { expected, new FixedBytes(left), new FixedBytes(right) }; } - yield return new object[] {null, null, new FixedBytes(new byte[] {0xFF})}; - yield return new object[] {null, new FixedBytes(new byte[] {0xFF}), null}; - yield return new object[] {null, null, null}; + yield return new object[] { null, null, new FixedBytes(new byte[] { 0xFF }) }; + yield return new object[] { null, new FixedBytes(new byte[] { 0xFF }), null }; + yield return new object[] { null, null, null }; IEnumerable<(byte[] left, byte[] right)> Values() { - yield return (new byte[] {0xFF}, Array.Empty()); - yield return (new byte[] {0x00}, new byte[] {0x00}); - yield return (new byte[] {0xF0}, new byte[] {0x0F}); - yield return (new byte[] {0x42}, new byte[] {0xBD}); - yield return (new byte[] {0xFF, 0xFF}, new byte[] {0xFF, 0x00}); - yield return (new byte[] {0xFF, 0xFF}, new byte[] {0x00, 0xFF}); - yield return (new byte[] {0xFF, 0xFF}, new byte[] {0x0A, 0xC0}); + yield return (new byte[] { 0xFF }, Array.Empty()); + yield return (new byte[] { 0x00 }, new byte[] { 0x00 }); + yield return (new byte[] { 0xF0 }, new byte[] { 0x0F }); + yield return (new byte[] { 0x42 }, new byte[] { 0xBD }); + yield return (new byte[] { 0xFF, 0xFF }, new byte[] { 0xFF, 0x00 }); + yield return (new byte[] { 0xFF, 0xFF }, new byte[] { 0x00, 0xFF }); + yield return (new byte[] { 0xFF, 0xFF }, new byte[] { 0x0A, 0xC0 }); } } @@ -339,8 +339,8 @@ public void Subtraction_Test(FixedBytes expected, public void Subtraction_LeftSmallerThanRight_Throws_InvalidOperationException_Test() { // Arrange - var left = new FixedBytes(new byte[] {0x00, 0xAC}); - var right = new FixedBytes(new byte[] {0xCA}); + var left = new FixedBytes(new byte[] { 0x00, 0xAC }); + var right = new FixedBytes(new byte[] { 0xCA }); // Act // Assert @@ -364,21 +364,21 @@ public static IEnumerable LogicalOr_Test_Values() foreach (var (right, left) in Values()) { var expected = new FixedBytes(ByteArrayUtils.BitwiseOrBigEndian(left, right)); - yield return new object[] {expected, new FixedBytes(right), new FixedBytes(left)}; + yield return new object[] { expected, new FixedBytes(right), new FixedBytes(left) }; } - yield return new object[] {null, null, new FixedBytes(new byte[] {0xFF})}; - yield return new object[] {null, new FixedBytes(new byte[] {0xFF}), null}; - yield return new object[] {null, null, null}; + yield return new object[] { null, null, new FixedBytes(new byte[] { 0xFF }) }; + yield return new object[] { null, new FixedBytes(new byte[] { 0xFF }), null }; + yield return new object[] { null, null, null }; IEnumerable<(byte[] left, byte[] right)> Values() { - yield return (new byte[] {0xFF}, Array.Empty()); - yield return (new byte[] {0x00}, new byte[] {0x00}); - yield return (new byte[] {0xF0}, new byte[] {0x0F}); - yield return (new byte[] {0x42}, new byte[] {0xBD}); - yield return (new byte[] {0xFF}, new byte[] {0xBD}); - yield return (new byte[] {0xFF, 0xFF}, new byte[] {0xBD}); + yield return (new byte[] { 0xFF }, Array.Empty()); + yield return (new byte[] { 0x00 }, new byte[] { 0x00 }); + yield return (new byte[] { 0xF0 }, new byte[] { 0x0F }); + yield return (new byte[] { 0x42 }, new byte[] { 0xBD }); + yield return (new byte[] { 0xFF }, new byte[] { 0xBD }); + yield return (new byte[] { 0xFF, 0xFF }, new byte[] { 0xBD }); } } @@ -404,21 +404,21 @@ public static IEnumerable LogicalAnd_Test_Values() foreach (var (left, right) in Values()) { var expected = new FixedBytes(ByteArrayUtils.BitwiseAndBigEndian(left, right)); - yield return new object[] {expected, new FixedBytes(left), new FixedBytes(right)}; + yield return new object[] { expected, new FixedBytes(left), new FixedBytes(right) }; } - yield return new object[] {null, null, new FixedBytes(new byte[] {0xFF})}; - yield return new object[] {null, new FixedBytes(new byte[] {0xFF}), null}; - yield return new object[] {null, null, null}; + yield return new object[] { null, null, new FixedBytes(new byte[] { 0xFF }) }; + yield return new object[] { null, new FixedBytes(new byte[] { 0xFF }), null }; + yield return new object[] { null, null, null }; IEnumerable<(byte[] left, byte[] right)> Values() { - yield return (new byte[] {0xFF}, Array.Empty()); - yield return (new byte[] {0x00}, new byte[] {0x00}); - yield return (new byte[] {0xF0}, new byte[] {0x0F}); - yield return (new byte[] {0x42}, new byte[] {0xBD}); - yield return (new byte[] {0xFF}, new byte[] {0xBD}); - yield return (new byte[] {0xFF, 0xFF}, new byte[] {0xBD}); + yield return (new byte[] { 0xFF }, Array.Empty()); + yield return (new byte[] { 0x00 }, new byte[] { 0x00 }); + yield return (new byte[] { 0xF0 }, new byte[] { 0x0F }); + yield return (new byte[] { 0x42 }, new byte[] { 0xBD }); + yield return (new byte[] { 0xFF }, new byte[] { 0xBD }); + yield return (new byte[] { 0xFF, 0xFF }, new byte[] { 0xBD }); } } @@ -444,21 +444,21 @@ public static IEnumerable LogicalXor_Test_Values() foreach (var (left, right) in Values()) { var expected = new FixedBytes(ByteArrayUtils.BitwiseXorBigEndian(left, right)); - yield return new object[] {expected, new FixedBytes(left), new FixedBytes(right)}; + yield return new object[] { expected, new FixedBytes(left), new FixedBytes(right) }; } - yield return new object[] {null, null, new FixedBytes(new byte[] {0xFF})}; - yield return new object[] {null, new FixedBytes(new byte[] {0xFF}), null}; - yield return new object[] {null, null, null}; + yield return new object[] { null, null, new FixedBytes(new byte[] { 0xFF }) }; + yield return new object[] { null, new FixedBytes(new byte[] { 0xFF }), null }; + yield return new object[] { null, null, null }; IEnumerable<(byte[] left, byte[] right)> Values() { - yield return (new byte[] {0xFF}, Array.Empty()); - yield return (new byte[] {0x00}, new byte[] {0x00}); - yield return (new byte[] {0xF0}, new byte[] {0x0F}); - yield return (new byte[] {0x42}, new byte[] {0xBD}); - yield return (new byte[] {0xFF}, new byte[] {0xBD}); - yield return (new byte[] {0xFF, 0xFF}, new byte[] {0xBD}); + yield return (new byte[] { 0xFF }, Array.Empty()); + yield return (new byte[] { 0x00 }, new byte[] { 0x00 }); + yield return (new byte[] { 0xF0 }, new byte[] { 0x0F }); + yield return (new byte[] { 0x42 }, new byte[] { 0xBD }); + yield return (new byte[] { 0xFF }, new byte[] { 0xBD }); + yield return (new byte[] { 0xFF, 0xFF }, new byte[] { 0xBD }); } } @@ -484,17 +484,17 @@ public static IEnumerable LogicalNot_Test_Values() foreach (var bytes in Values()) { var expected = new FixedBytes(ByteArrayUtils.BitwiseNot(bytes)); - yield return new object[] {expected, new FixedBytes(bytes)}; + yield return new object[] { expected, new FixedBytes(bytes) }; } - yield return new object[] {null, null}; + yield return new object[] { null, null }; IEnumerable Values() { yield return Array.Empty(); - yield return new byte[] {0x00}; - yield return new byte[] {0x0F}; - yield return new byte[] {0xAC, 0xCA}; + yield return new byte[] { 0x00 }; + yield return new byte[] { 0x0F }; + yield return new byte[] { 0xAC, 0xCA }; } } @@ -517,23 +517,23 @@ public void LogicalNot_Test(FixedBytes expected, public static IEnumerable LogicalLeftShift_Test_Values() { - foreach (var shift in new[] {0, 1, 8, 32}) + foreach (var shift in new[] { 0, 1, 8, 32 }) { foreach (var bytes in Values()) { var expected = new FixedBytes(bytes.ShiftBitsLeft(shift)); - yield return new object[] {expected, new FixedBytes(bytes), shift}; + yield return new object[] { expected, new FixedBytes(bytes), shift }; } } - yield return new object[] {null, null, 42}; + yield return new object[] { null, null, 42 }; IEnumerable Values() { yield return Array.Empty(); - yield return new byte[] {0x00}; - yield return new byte[] {0x0F}; - yield return new byte[] {0xAC, 0xCA}; + yield return new byte[] { 0x00 }; + yield return new byte[] { 0x0F }; + yield return new byte[] { 0xAC, 0xCA }; } } @@ -555,7 +555,7 @@ public void LogicalLeftShift_Test(FixedBytes expected, public void LogicalLeftShift_ShiftLessThan0_Throws_ArgumentException_TestTest() { // Arrange - var fixedBytes = new FixedBytes(new byte[] {0x00}); + var fixedBytes = new FixedBytes(new byte[] { 0x00 }); // Act // Assert @@ -572,23 +572,23 @@ public void LogicalLeftShift_ShiftLessThan0_Throws_ArgumentException_TestTest() public static IEnumerable LogicalRightShift_Test_Values() { - foreach (var shift in new[] {0, 1, 8, 32}) + foreach (var shift in new[] { 0, 1, 8, 32 }) { foreach (var bytes in Values()) { var expected = new FixedBytes(bytes.ShiftBitsRight(shift)); - yield return new object[] {expected, new FixedBytes(bytes), shift}; + yield return new object[] { expected, new FixedBytes(bytes), shift }; } } - yield return new object[] {null, null, 42}; + yield return new object[] { null, null, 42 }; IEnumerable Values() { yield return Array.Empty(); - yield return new byte[] {0x00}; - yield return new byte[] {0x0F}; - yield return new byte[] {0xAC, 0xCA}; + yield return new byte[] { 0x00 }; + yield return new byte[] { 0x0F }; + yield return new byte[] { 0xAC, 0xCA }; } } @@ -610,7 +610,7 @@ public void LogicalRightShift_Test(FixedBytes expected, public void LogicalRightShift_ShiftLessThan0_Throws_ArgumentException_TestTest() { // Arrange - var fixedBytes = new FixedBytes(new byte[] {0x00}); + var fixedBytes = new FixedBytes(new byte[] { 0x00 }); // Act // Assert @@ -633,7 +633,7 @@ public void LogicalRightShift_ShiftLessThan0_Throws_ArgumentException_TestTest() public void Explicit_FixedBytes_To_ByteArray_Test() { // Arrange - var bytes = new byte[] {0x00, 0xAC, 0xCA}; + var bytes = new byte[] { 0x00, 0xAC, 0xCA }; var fixedBytes = new FixedBytes(bytes); // Act @@ -650,7 +650,7 @@ public void Explicit_FixedBytes_To_ByteArray_Null_Returns_Null_Test() // Arrange // Act // ReSharper disable once ExpressionIsAlwaysNull - byte[] asBytes = (FixedBytes) null; + byte[] asBytes = (FixedBytes)null; // Assert Assert.Null(asBytes); @@ -664,10 +664,10 @@ public void Explicit_FixedBytes_To_ByteArray_Null_Returns_Null_Test() public void Explicit_ByteArray_To_FixedBytes_Test() { // Arrange - var bytes = new byte[] {0x00, 0xAC, 0xCA}; + var bytes = new byte[] { 0x00, 0xAC, 0xCA }; // Act - var fixedBytes = (FixedBytes) bytes; + var fixedBytes = (FixedBytes)bytes; // Assert Assert.NotNull(fixedBytes); @@ -680,7 +680,7 @@ public void Explicit_ByteArray_To_FixedBytes_Null_Returns_Null_Test() { // Arrange // Act - var fixedBytes = (FixedBytes) (byte[]) null; + var fixedBytes = (FixedBytes)(byte[])null; // Assert Assert.Null(fixedBytes); @@ -690,10 +690,10 @@ public void Explicit_ByteArray_To_FixedBytes_Null_Returns_Null_Test() public void Explicit_ByteList_To_FixedBytes_Test() { // Arrange - var bytes = new byte[] {0x00, 0xAC, 0xCA}.ToList(); + var bytes = new byte[] { 0x00, 0xAC, 0xCA }.ToList(); // Act - var fixedBytes = (FixedBytes) bytes; + var fixedBytes = (FixedBytes)bytes; // Assert Assert.NotNull(fixedBytes); @@ -706,7 +706,7 @@ public void Explicit_ByteList_To_FixedBytes_Null_Returns_Null_Test() { // Arrange // Act - var fixedBytes = (FixedBytes) (List) null; + var fixedBytes = (FixedBytes)(List)null; // Assert Assert.Null(fixedBytes); @@ -721,21 +721,21 @@ public static IEnumerable Comparision_GreaterThan_Test_Values() // expected: Left > Right // compare to self var self = new FixedBytes(Array.Empty()); - yield return new object[] {false, self, self}; + yield return new object[] { false, self, self }; // compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {false, new FixedBytes(sameBytes), new FixedBytes(sameBytes)}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { false, new FixedBytes(sameBytes), new FixedBytes(sameBytes) }; // compare less than value - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0xFF})}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0xFF }) }; // compare to greater than value - yield return new object[] {true, new FixedBytes(new byte[] {0xFF}), new FixedBytes(new byte[] {0x00})}; + yield return new object[] { true, new FixedBytes(new byte[] { 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; // compare to greater than value of different sizes - yield return new object[] {true, new FixedBytes(new byte[] {0x00, 0xFF}), new FixedBytes(new byte[] {0x00})}; - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0x00, 0xFF})}; + yield return new object[] { true, new FixedBytes(new byte[] { 0x00, 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0x00, 0xFF }) }; } [Theory] @@ -756,21 +756,21 @@ public static IEnumerable Comparision_LessThan_Test_Values() // expected: Left < Right // compare to self var self = new FixedBytes(Array.Empty()); - yield return new object[] {false, self, self}; + yield return new object[] { false, self, self }; // compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {false, new FixedBytes(sameBytes), new FixedBytes(sameBytes)}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { false, new FixedBytes(sameBytes), new FixedBytes(sameBytes) }; // compare less than value - yield return new object[] {true, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0xFF})}; + yield return new object[] { true, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0xFF }) }; // compare to greater than value - yield return new object[] {false, new FixedBytes(new byte[] {0xFF}), new FixedBytes(new byte[] {0x00})}; + yield return new object[] { false, new FixedBytes(new byte[] { 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; // compare to greater than value of different sizes - yield return new object[] {false, new FixedBytes(new byte[] {0x00, 0xFF}), new FixedBytes(new byte[] {0x00})}; - yield return new object[] {true, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0x00, 0xFF})}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00, 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; + yield return new object[] { true, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0x00, 0xFF }) }; } [Theory] @@ -792,21 +792,21 @@ public static IEnumerable Comparision_GreaterThanOrEquals_FixedBytes_T // expected: Left >= Right // compare to self var self = new FixedBytes(Array.Empty()); - yield return new object[] {true, self, self}; + yield return new object[] { true, self, self }; // compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {true, new FixedBytes(sameBytes), new FixedBytes(sameBytes)}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { true, new FixedBytes(sameBytes), new FixedBytes(sameBytes) }; // compare less than value - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0xFF})}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0xFF }) }; // compare to greater than value - yield return new object[] {true, new FixedBytes(new byte[] {0xFF}), new FixedBytes(new byte[] {0x00})}; + yield return new object[] { true, new FixedBytes(new byte[] { 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; // compare to greater than value of different sizes - yield return new object[] {true, new FixedBytes(new byte[] {0x00, 0xFF}), new FixedBytes(new byte[] {0x00})}; - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0x00, 0xFF})}; + yield return new object[] { true, new FixedBytes(new byte[] { 0x00, 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0x00, 0xFF }) }; } [Theory] @@ -828,21 +828,21 @@ public static IEnumerable Comparision_LessThanOrEquals_FixedBytes_Test // expected: Left <= Right // compare to self var self = new FixedBytes(Array.Empty()); - yield return new object[] {true, self, self}; + yield return new object[] { true, self, self }; // compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {true, new FixedBytes(sameBytes), new FixedBytes(sameBytes)}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { true, new FixedBytes(sameBytes), new FixedBytes(sameBytes) }; // compare less than value - yield return new object[] {true, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0xFF})}; + yield return new object[] { true, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0xFF }) }; // compare to greater than value - yield return new object[] {false, new FixedBytes(new byte[] {0xFF}), new FixedBytes(new byte[] {0x00})}; + yield return new object[] { false, new FixedBytes(new byte[] { 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; // compare to greater than value of different sizes - yield return new object[] {false, new FixedBytes(new byte[] {0x00, 0xFF}), new FixedBytes(new byte[] {0x00})}; - yield return new object[] {true, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0x00, 0xFF})}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00, 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; + yield return new object[] { true, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0x00, 0xFF }) }; } [Theory] @@ -863,14 +863,14 @@ public static IEnumerable Comparision_Equal_Test_Values() { // equality compare to self var self = new FixedBytes(Array.Empty()); - yield return new object[] {true, self, self}; + yield return new object[] { true, self, self }; // equality compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {true, new FixedBytes(sameBytes), new FixedBytes(sameBytes)}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { true, new FixedBytes(sameBytes), new FixedBytes(sameBytes) }; - yield return new object[] {true, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0x00, 0x00})}; - yield return new object[] {true, new FixedBytes(new byte[] {0xFF}), new FixedBytes(new byte[] {0x00, 0xFF})}; + yield return new object[] { true, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0x00, 0x00 }) }; + yield return new object[] { true, new FixedBytes(new byte[] { 0xFF }), new FixedBytes(new byte[] { 0x00, 0xFF }) }; } [Theory] @@ -903,7 +903,7 @@ public void Comparision_Equal_Test(bool expected, public void Comparision_ToNull_Test() { // Arrange - var fixedByte = new FixedBytes(new byte[] {0x00}); + var fixedByte = new FixedBytes(new byte[] { 0x00 }); // Act // Assert operator == @@ -946,24 +946,24 @@ public void Comparision_ToNull_Test() public static IEnumerable CompareTo_FixedBytes_Test_Values() { // compare to null - yield return new object[] {1, new FixedBytes(Array.Empty()), null}; + yield return new object[] { 1, new FixedBytes(Array.Empty()), null }; // compare to self var self = new FixedBytes(Array.Empty()); - yield return new object[] {0, self, self}; + yield return new object[] { 0, self, self }; // compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {0, new FixedBytes(sameBytes), new FixedBytes(sameBytes)}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { 0, new FixedBytes(sameBytes), new FixedBytes(sameBytes) }; - yield return new object[] { -1, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0xFF})}; - yield return new object[] {1, new FixedBytes(new byte[] {0xFF}), new FixedBytes(new byte[] {0x00})}; + yield return new object[] { -1, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0xFF }) }; + yield return new object[] { 1, new FixedBytes(new byte[] { 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; - yield return new object[] { -1, new FixedBytes(new byte[] {0x00, 0x00}), new FixedBytes(new byte[] {0xFF})}; - yield return new object[] {1, new FixedBytes(new byte[] {0xFF}), new FixedBytes(new byte[] {0x00, 0x00})}; + yield return new object[] { -1, new FixedBytes(new byte[] { 0x00, 0x00 }), new FixedBytes(new byte[] { 0xFF }) }; + yield return new object[] { 1, new FixedBytes(new byte[] { 0xFF }), new FixedBytes(new byte[] { 0x00, 0x00 }) }; - yield return new object[] { -1, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0x00, 0xFF})}; - yield return new object[] {1, new FixedBytes(new byte[] {0x00, 0xFF}), new FixedBytes(new byte[] {0x00})}; + yield return new object[] { -1, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0x00, 0xFF }) }; + yield return new object[] { 1, new FixedBytes(new byte[] { 0x00, 0xFF }), new FixedBytes(new byte[] { 0x00 }) }; } [Theory] @@ -976,7 +976,7 @@ public void CompareTo_FixedBytes_Test(int expected, // Act // Assert Assert.Equal(expected, fixedBytes.CompareTo(comparedTo)); - Assert.Equal(expected, fixedBytes.CompareTo((FixedBytes) comparedTo)); + Assert.Equal(expected, fixedBytes.CompareTo((FixedBytes)comparedTo)); } #endregion @@ -986,20 +986,20 @@ public void CompareTo_FixedBytes_Test(int expected, public static IEnumerable CompareTo_Bytes_Test_Values() { // compare to null - yield return new object[] {1, new FixedBytes(Array.Empty()), null}; + yield return new object[] { 1, new FixedBytes(Array.Empty()), null }; // compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {0, new FixedBytes(sameBytes), sameBytes}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { 0, new FixedBytes(sameBytes), sameBytes }; - yield return new object[] { -1, new FixedBytes(new byte[] {0x00}), new byte[] {0xFF}}; - yield return new object[] {1, new FixedBytes(new byte[] {0xFF}), new byte[] {0x00}}; + yield return new object[] { -1, new FixedBytes(new byte[] { 0x00 }), new byte[] { 0xFF } }; + yield return new object[] { 1, new FixedBytes(new byte[] { 0xFF }), new byte[] { 0x00 } }; - yield return new object[] { -1, new FixedBytes(new byte[] {0x00, 0x00}), new byte[] {0xFF}}; - yield return new object[] {1, new FixedBytes(new byte[] {0xFF}), new byte[] {0x00, 0x00}}; + yield return new object[] { -1, new FixedBytes(new byte[] { 0x00, 0x00 }), new byte[] { 0xFF } }; + yield return new object[] { 1, new FixedBytes(new byte[] { 0xFF }), new byte[] { 0x00, 0x00 } }; - yield return new object[] { -1, new FixedBytes(new byte[] {0x00}), new byte[] {0x00, 0xFF}}; - yield return new object[] {1, new FixedBytes(new byte[] {0x00, 0xFF}), new byte[] {0x00}}; + yield return new object[] { -1, new FixedBytes(new byte[] { 0x00 }), new byte[] { 0x00, 0xFF } }; + yield return new object[] { 1, new FixedBytes(new byte[] { 0x00, 0xFF }), new byte[] { 0x00 } }; } [Theory] @@ -1032,14 +1032,14 @@ public static IEnumerable Comparision_Exactly_Test_Values() { // equality compare to self var self = new FixedBytes(Array.Empty()); - yield return new object[] {true, self, self}; + yield return new object[] { true, self, self }; // equality compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {true, new FixedBytes(sameBytes), new FixedBytes(sameBytes)}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { true, new FixedBytes(sameBytes), new FixedBytes(sameBytes) }; - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new FixedBytes(new byte[] {0x00, 0x00})}; - yield return new object[] {false, new FixedBytes(new byte[] {0xFF}), new FixedBytes(new byte[] {0x00, 0xFF})}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new FixedBytes(new byte[] { 0x00, 0x00 }) }; + yield return new object[] { false, new FixedBytes(new byte[] { 0xFF }), new FixedBytes(new byte[] { 0x00, 0xFF }) }; } [Theory] @@ -1062,20 +1062,20 @@ public void Comparision_Exactly_Test(bool expected, public static IEnumerable Exactly_Bytes_Test_Values() { // equality compare to null - yield return new object[] {false, new FixedBytes(Array.Empty()), null}; + yield return new object[] { false, new FixedBytes(Array.Empty()), null }; // equality compare to equal valued bytes - var sameBytes = new byte[] {0xAC, 0xCA}; - yield return new object[] {true, new FixedBytes(sameBytes), sameBytes}; + var sameBytes = new byte[] { 0xAC, 0xCA }; + yield return new object[] { true, new FixedBytes(sameBytes), sameBytes }; // equality compare non-equal bytes by length - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new byte[] {0xFF, 0xFF}}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new byte[] { 0xFF, 0xFF } }; // equality compare non-equal bytes - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new byte[] {0xFF}}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new byte[] { 0xFF } }; - yield return new object[] {false, new FixedBytes(new byte[] {0x00}), new byte[] {0x00, 0x00}}; - yield return new object[] {false, new FixedBytes(new byte[] {0xFF}), new byte[] {0x00, 0xFF}}; + yield return new object[] { false, new FixedBytes(new byte[] { 0x00 }), new byte[] { 0x00, 0x00 } }; + yield return new object[] { false, new FixedBytes(new byte[] { 0xFF }), new byte[] { 0x00, 0xFF } }; } [Theory] @@ -1101,8 +1101,8 @@ public void Exactly_Bytes_Test(bool expected, public static IEnumerable GetHashCode_SameByteValue_Collides_Test_Values() { yield return new object[] { Array.Empty() }; - yield return new object[] {new byte[] {0x00}}; - yield return new object[] {new byte[] {0xAC, 0xCA}}; + yield return new object[] { new byte[] { 0x00 } }; + yield return new object[] { new byte[] { 0xAC, 0xCA } }; } [Theory] @@ -1123,7 +1123,7 @@ public void GetHashCode_SameByteValue_Collides_Test(byte[] bytes) public void GetHashCode_LargeBytes_Test() { // Arrange - var lotsOfBytes = Enumerable.Repeat((byte) 0xCA, 100); + var lotsOfBytes = Enumerable.Repeat((byte)0xCA, 100); var fixedBytes = new FixedBytes(lotsOfBytes); // Act @@ -1142,7 +1142,7 @@ public void GetHashCode_LargeBytes_Test() public void Indexer_Test() { // Arrange - var bytes = new byte[] {0x00, 0xAC, 0xCA, 0xFF}; + var bytes = new byte[] { 0x00, 0xAC, 0xCA, 0xFF }; var fixedBytes = new FixedBytes(bytes); // Act @@ -1173,7 +1173,7 @@ public void Indexer_Index_LessThan0_Throws_ArgumentOutOfRangeException_Test() public void Indexer_Index_GreaterThanCount_Throws_ArgumentOutOfRangeException_Test() { // Arrange - var fixedBytes = new FixedBytes(new byte[] {0xAC, 0xCA}); + var fixedBytes = new FixedBytes(new byte[] { 0xAC, 0xCA }); // Act // Assert @@ -1192,7 +1192,7 @@ public void Indexer_Index_GreaterThanCount_Throws_ArgumentOutOfRangeException_Te public void ToString_Default_Test() { // Arrange - var fixedBytes = new FixedBytes(new byte[] {0xAC, 0xFF, 0xCA}); + var fixedBytes = new FixedBytes(new byte[] { 0xAC, 0xFF, 0xCA }); // Act var result = fixedBytes.ToString(); @@ -1210,21 +1210,21 @@ public static IEnumerable ToString_Format_Test_Values() foreach (var format in Formats()) { var expected = bytes.ToString(format, formatProvider); - yield return new object[] {expected, new FixedBytes(bytes), format, formatProvider}; + yield return new object[] { expected, new FixedBytes(bytes), format, formatProvider }; } } IEnumerable Formats() { - return new[] {null, string.Empty, "g", "G", "H", "h", "HC", "hc", "d", "D", "o", "O", "b", "B", "bc", "BC", "I", "IBE", "ILE"}; + return new[] { null, string.Empty, "g", "G", "H", "h", "HC", "hc", "d", "D", "o", "O", "b", "B", "bc", "BC", "I", "IBE", "ILE" }; } IEnumerable Values() { yield return Array.Empty(); - yield return new byte[] {0x00}; - yield return new byte[] {0x0F}; - yield return new byte[] {0xAC, 0xCA}; + yield return new byte[] { 0x00 }; + yield return new byte[] { 0x0F }; + yield return new byte[] { 0xAC, 0xCA }; } } diff --git a/src/Gulliver.Tests/Gulliver.Tests.csproj b/src/Gulliver.Tests/Gulliver.Tests.csproj index 2d96893..c1f7026 100644 --- a/src/Gulliver.Tests/Gulliver.Tests.csproj +++ b/src/Gulliver.Tests/Gulliver.Tests.csproj @@ -8,6 +8,9 @@ Unit test package for Gulliver Sandia National Laboratories Sandia National Laboratories + Debug + AnyCPU + IOperation diff --git a/src/Gulliver/ByteArrayUtils.cs b/src/Gulliver/ByteArrayUtils.cs index 393cc12..b6807bf 100644 --- a/src/Gulliver/ByteArrayUtils.cs +++ b/src/Gulliver/ByteArrayUtils.cs @@ -79,7 +79,7 @@ public static byte[] BitwiseNot([NotNull] byte[] bytes) for (var i = 0; i < bytes.Length; i++) { - result[i] = (byte) ~bytes[i]; + result[i] = (byte)~bytes[i]; } return result; @@ -210,8 +210,8 @@ public static byte[] ShiftBitsLeft([NotNull] this byte[] bytes, { // shift one byte (8 bits) at a time var sourceByte = bytes[i]; - var resultByte = (byte) (sourceByte << shiftOffset); // left shift source byte by the bit shift offset creating a 0-suffixed bits - var carryByte = (byte) (sourceByte >> (8 - shiftOffset)); // right shift source byte so that its value is equivalent to the carry of the above left shift operation + var resultByte = (byte)(sourceByte << shiftOffset); // left shift source byte by the bit shift offset creating a 0-suffixed bits + var carryByte = (byte)(sourceByte >> (8 - shiftOffset)); // right shift source byte so that its value is equivalent to the carry of the above left shift operation var resultIndex = i - byteOffset; //length - 1 - byteOffset + i -1; var carryIndex = resultIndex - 1; @@ -333,8 +333,8 @@ public static byte[] ShiftBitsRight([NotNull] this byte[] bytes, { // shift one byte (8 bits) at a time var sourceByte = bytes[i]; - var resultByte = (byte) (sourceByte >> shiftOffset); // right shift source byte by the bit shift offset creating a 0-prefixed bits - var carryByte = (byte) (sourceByte << (8 - shiftOffset)); // left shift source byte so that its value is equivalent to the carry of the above right shift operation + var resultByte = (byte)(sourceByte >> shiftOffset); // right shift source byte by the bit shift offset creating a 0-prefixed bits + var carryByte = (byte)(sourceByte << (8 - shiftOffset)); // left shift source byte so that its value is equivalent to the carry of the above right shift operation var resultIndex = i + byteOffset; var carryIndex = resultIndex + 1; // the cary byte sits on byte after the destination byte diff --git a/src/Gulliver/ByteArrayUtils_BigEndian.cs b/src/Gulliver/ByteArrayUtils_BigEndian.cs index a4dd370..12b1845 100644 --- a/src/Gulliver/ByteArrayUtils_BigEndian.cs +++ b/src/Gulliver/ByteArrayUtils_BigEndian.cs @@ -198,7 +198,7 @@ byte[] GetBigEndianAbsBytes(long input) // long.MinValue (-9223372036854775808) is a special case // getting the absolute value of a the minimum value of a twos complement number is invalid and will cause a OverflowException // We must therefor build the equivalent of abs(long.MinValue) big endian bytes manually - return new byte[] {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + return new byte[] { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; } var bytes = BitConverter.GetBytes(Math.Abs(input)); @@ -277,13 +277,13 @@ public static byte[] AddUnsignedBigEndian([NotNull] byte[] right, { var sum = carry + leftByte + rightByte; - resultStack.Push((byte) (sum & 0xFF)); // push the byte value of sum + resultStack.Push((byte)(sum & 0xFF)); // push the byte value of sum carry = sum >> 8; // new carry value is sum shifted by 8 bits (a byte) } if (carry != 0) // if a carry value exists it should be pushed as it is the new MSB { - resultStack.Push((byte) carry); // push carry + resultStack.Push((byte)carry); // push carry } return resultStack.ToArray(); @@ -390,7 +390,7 @@ public static byte[] SubtractUnsignedBigEndian([NotNull] byte[] left, if (borrowed && canBorrow) // previous operation needed to borrow, and a borrow is possible { - minuend = (byte) (leftByte - 1); // decrement as this value has been borrowed from in the previous iteration + minuend = (byte)(leftByte - 1); // decrement as this value has been borrowed from in the previous iteration } else if (borrowed) // && !canBorrow (implied) { @@ -403,14 +403,14 @@ public static byte[] SubtractUnsignedBigEndian([NotNull] byte[] left, if (minuend >= rightByte) // left is big enough to subtract right { - var difference = (byte) (minuend - rightByte); + var difference = (byte)(minuend - rightByte); resultStack.Push(difference); borrowed = borrowed && !canBorrow; // set borrow if a borrow happened some time previously but it could not be accommodated in this iteration; borrow from next } else // left is less than right, automatically borrow from next iteration { - var difference = (byte) ((minuend + 0x0100) - rightByte); // handle borrowed + var difference = (byte)((minuend + 0x0100) - rightByte); // handle borrowed resultStack.Push(difference); borrowed = true; } @@ -471,7 +471,7 @@ public static byte[] BitwiseAndBigEndian([NotNull] byte[] left, //return result; return new ConcurrentBigEndianByteEnumerable(left, right, false) - .Select(bytes => (byte) (bytes.leftByte & bytes.rightByte)) + .Select(bytes => (byte)(bytes.leftByte & bytes.rightByte)) .ToArray(); } @@ -522,7 +522,7 @@ public static byte[] BitwiseOrBigEndian([NotNull] byte[] left, //return result; return new ConcurrentBigEndianByteEnumerable(left, right, false) - .Select(bytes => (byte) (bytes.leftByte | bytes.rightByte)) + .Select(bytes => (byte)(bytes.leftByte | bytes.rightByte)) .ToArray(); } @@ -573,7 +573,7 @@ public static byte[] BitwiseXorBigEndian([NotNull] byte[] left, //return result; return new ConcurrentBigEndianByteEnumerable(left, right, false) - .Select(bytes => (byte) (bytes.leftByte ^ bytes.rightByte)) + .Select(bytes => (byte)(bytes.leftByte ^ bytes.rightByte)) .ToArray(); } diff --git a/src/Gulliver/ByteArrayUtils_Conversion.cs b/src/Gulliver/ByteArrayUtils_Conversion.cs index 6924c2c..e6d629e 100644 --- a/src/Gulliver/ByteArrayUtils_Conversion.cs +++ b/src/Gulliver/ByteArrayUtils_Conversion.cs @@ -151,7 +151,7 @@ string DelimitedBaseConverter(byte[] input, int? paddingWidth = null, char paddingChar = '0') { - if (!new[] {2, 8, 10, 16}.Contains(@base)) + if (!new[] { 2, 8, 10, 16 }.Contains(@base)) { throw new ArgumentException($"{nameof(@base)} must be 2, 8, 10, or 16 (binary, octal, decimal, or hexadecimal respectively)", nameof(@base)); } diff --git a/src/Gulliver/ByteArrayUtils_LittleEndian.cs b/src/Gulliver/ByteArrayUtils_LittleEndian.cs index 0e2ad5c..55c1ca6 100644 --- a/src/Gulliver/ByteArrayUtils_LittleEndian.cs +++ b/src/Gulliver/ByteArrayUtils_LittleEndian.cs @@ -199,7 +199,7 @@ byte[] GetLittleEndianAbsBytes(long input) // long.MinValue (-9223372036854775808) is a special case // getting the absolute value of a the minimum value of a twos complement number is invalid and will cause a OverflowException // We must therefor build the equivalent of abs(long.MinValue) little endian bytes manually - return new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80}; + return new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 }; } var bytes = BitConverter.GetBytes(Math.Abs(input)); @@ -272,13 +272,13 @@ public static byte[] AddUnsignedLittleEndian([NotNull] byte[] left, { var sum = carry + leftByte + rightByte; - resultQueue.Enqueue((byte) (sum & 0xFF)); // push the byte value of sum + resultQueue.Enqueue((byte)(sum & 0xFF)); // push the byte value of sum carry = sum >> 8; // new carry value is sum shifted by 8 bits (a byte) } if (carry != 0) // if a carry value exists it should be pushed as it is the new MSB { - resultQueue.Enqueue((byte) carry); // enqueue carry + resultQueue.Enqueue((byte)carry); // enqueue carry } return resultQueue.ToArray(); @@ -327,7 +327,7 @@ public static byte[] SubtractUnsignedLittleEndian([NotNull] byte[] left, if (borrowed && canBorrow) // previous operation needed to borrow, and a borrow is possible { - minuend = (byte) (leftByte - 1); // decrement as this value has been borrowed from in the previous iteration + minuend = (byte)(leftByte - 1); // decrement as this value has been borrowed from in the previous iteration } else if (borrowed) // && !canBorrow (implied) { @@ -340,14 +340,14 @@ public static byte[] SubtractUnsignedLittleEndian([NotNull] byte[] left, if (minuend >= rightByte) // left is big enough to subtract right { - var difference = (byte) (minuend - rightByte); + var difference = (byte)(minuend - rightByte); resultQueue.Enqueue(difference); borrowed = borrowed && !canBorrow; // set borrow if a borrow happened some time previously but it could not be accommodated in this iteration; borrow from next } else // left is less than right, automatically borrow from next iteration { - var difference = (byte) ((minuend + 0x0100) - rightByte); // handle borrowed + var difference = (byte)((minuend + 0x0100) - rightByte); // handle borrowed resultQueue.Enqueue(difference); borrowed = true; } @@ -405,7 +405,7 @@ public static byte[] BitwiseAndLittleEndian([NotNull] byte[] left, //return result; return new ConcurrentLittleEndianByteEnumerable(left, right, false) - .Select(bytes => (byte) (bytes.leftByte & bytes.rightByte)) + .Select(bytes => (byte)(bytes.leftByte & bytes.rightByte)) .ToArray(); } @@ -453,7 +453,7 @@ public static byte[] BitwiseOrLittleEndian([NotNull] byte[] left, //return result; return new ConcurrentLittleEndianByteEnumerable(left, right, false) - .Select(bytes => (byte) (bytes.leftByte | bytes.rightByte)) + .Select(bytes => (byte)(bytes.leftByte | bytes.rightByte)) .ToArray(); } @@ -501,7 +501,7 @@ public static byte[] BitwiseXorLittleEndian([NotNull] byte[] left, //return result; return new ConcurrentLittleEndianByteEnumerable(left, right, false) - .Select(bytes => (byte) (bytes.leftByte ^ bytes.rightByte)) + .Select(bytes => (byte)(bytes.leftByte ^ bytes.rightByte)) .ToArray(); } diff --git a/src/Gulliver/Enumerables/ConcurrentBigEndianByteEnumerable.cs b/src/Gulliver/Enumerables/ConcurrentBigEndianByteEnumerable.cs index a4cac2a..7b9d144 100644 --- a/src/Gulliver/Enumerables/ConcurrentBigEndianByteEnumerable.cs +++ b/src/Gulliver/Enumerables/ConcurrentBigEndianByteEnumerable.cs @@ -40,28 +40,28 @@ public ConcurrentBigEndianByteEnumerable([NotNull] IEnumerable left, using (var leftEnumerator = Left.GetReverseEnumerator()) // enumerate in reverse { using (var rightEnumerator = Right.GetReverseEnumerator()) - { - for (var i = count - 1; i >= 0; i--) { - byte leftByte = 0x00; - byte rightByte = 0x00; - - if (i + leftCount >= count) + for (var i = count - 1; i >= 0; i--) { - leftEnumerator.MoveNext(); - leftByte = leftEnumerator.Current; - } + byte leftByte = 0x00; + byte rightByte = 0x00; - if (i + rightCount >= count) - { - rightEnumerator.MoveNext(); - rightByte = rightEnumerator.Current; - } + if (i + leftCount >= count) + { + leftEnumerator.MoveNext(); + leftByte = leftEnumerator.Current; + } + + if (i + rightCount >= count) + { + rightEnumerator.MoveNext(); + rightByte = rightEnumerator.Current; + } - yield return (leftByte, rightByte); + yield return (leftByte, rightByte); + } } } - } } /// @@ -74,28 +74,28 @@ public ConcurrentBigEndianByteEnumerable([NotNull] IEnumerable left, using (var leftEnumerator = Left.GetEnumerator()) { using (var rightEnumerator = Right.GetEnumerator()) - { - for (var i = 0; i < count; i++) { - byte leftByte = 0x00; - byte rightByte = 0x00; - - if (i + leftCount >= count) + for (var i = 0; i < count; i++) { - leftEnumerator.MoveNext(); - leftByte = leftEnumerator.Current; - } + byte leftByte = 0x00; + byte rightByte = 0x00; - if (i + rightCount >= count) - { - rightEnumerator.MoveNext(); - rightByte = rightEnumerator.Current; - } + if (i + leftCount >= count) + { + leftEnumerator.MoveNext(); + leftByte = leftEnumerator.Current; + } + + if (i + rightCount >= count) + { + rightEnumerator.MoveNext(); + rightByte = rightEnumerator.Current; + } - yield return (leftByte, rightByte); + yield return (leftByte, rightByte); + } } } - } } } } diff --git a/src/Gulliver/Enumerables/ConcurrentLittleEndianByteEnumerable.cs b/src/Gulliver/Enumerables/ConcurrentLittleEndianByteEnumerable.cs index 97e0815..03ab69c 100644 --- a/src/Gulliver/Enumerables/ConcurrentLittleEndianByteEnumerable.cs +++ b/src/Gulliver/Enumerables/ConcurrentLittleEndianByteEnumerable.cs @@ -36,28 +36,28 @@ public ConcurrentLittleEndianByteEnumerable([NotNull] IEnumerable left, using (var leftEnumerator = Left.GetReverseEnumerator()) // enumerate in reverse { using (var rightEnumerator = Right.GetReverseEnumerator()) - { - for (var i = 0; i < count; i++) { - byte leftByte = 0x00; - byte rightByte = 0x00; - - if (i + leftCount >= count) + for (var i = 0; i < count; i++) { - leftEnumerator.MoveNext(); - leftByte = leftEnumerator.Current; - } + byte leftByte = 0x00; + byte rightByte = 0x00; - if (i + rightCount >= count) - { - rightEnumerator.MoveNext(); - rightByte = rightEnumerator.Current; - } + if (i + leftCount >= count) + { + leftEnumerator.MoveNext(); + leftByte = leftEnumerator.Current; + } + + if (i + rightCount >= count) + { + rightEnumerator.MoveNext(); + rightByte = rightEnumerator.Current; + } - yield return (leftByte, rightByte); + yield return (leftByte, rightByte); + } } } - } } /// @@ -70,28 +70,28 @@ public ConcurrentLittleEndianByteEnumerable([NotNull] IEnumerable left, using (var leftEnumerator = Left.GetEnumerator()) { using (var rightEnumerator = Right.GetEnumerator()) - { - for (var i = count - 1; i >= 0; i--) { - byte leftByte = 0x00; - byte rightByte = 0x00; - - if (i + leftCount >= count) + for (var i = count - 1; i >= 0; i--) { - leftEnumerator.MoveNext(); - leftByte = leftEnumerator.Current; - } + byte leftByte = 0x00; + byte rightByte = 0x00; - if (i + rightCount >= count) - { - rightEnumerator.MoveNext(); - rightByte = rightEnumerator.Current; - } + if (i + leftCount >= count) + { + leftEnumerator.MoveNext(); + leftByte = leftEnumerator.Current; + } + + if (i + rightCount >= count) + { + rightEnumerator.MoveNext(); + rightByte = rightEnumerator.Current; + } - yield return (leftByte, rightByte); + yield return (leftByte, rightByte); + } } } - } } } } diff --git a/src/Gulliver/FixedBytes.cs b/src/Gulliver/FixedBytes.cs index b138210..af58a70 100644 --- a/src/Gulliver/FixedBytes.cs +++ b/src/Gulliver/FixedBytes.cs @@ -288,7 +288,7 @@ public override bool Equals(object obj) { return !ReferenceEquals(null, obj) && (ReferenceEquals(this, obj) - || (obj.GetType() == GetType() && this.Equals((FixedBytes) obj))); + || (obj.GetType() == GetType() && this.Equals((FixedBytes)obj))); } ///