diff --git a/RevolveUavcan/Tools/BitArrayTools.cs b/RevolveUavcan/Tools/BitArrayTools.cs index 323d77e..5c3f561 100644 --- a/RevolveUavcan/Tools/BitArrayTools.cs +++ b/RevolveUavcan/Tools/BitArrayTools.cs @@ -114,27 +114,6 @@ private static BitArray FillBitArrayWithMSB(this BitArray bitArray, int finalSiz return template; } - /// - /// Calculate the ulong value of a BitArray - /// - /// The BitArray we want to calculate the corresponding ulong value for - /// An integer representation of the BitArray - public static ulong GetULongFromBitArray(this BitArray bitArray) - { - if (bitArray.Length > 64) - { - throw new ArgumentException("BitArray length cannot be greater than 64 bits."); - } - - // Initialize bitArrayWithMsb with values from bitArray and fill it with MSB - BitArray bitArrayWithMsb = FillBitArrayWithMSB(bitArray, 64); - - // Find and return corresponding integer value from bitArrayWithMsb - int[] array = new int[2]; - bitArrayWithMsb.CopyTo(array, 0); - return (uint)array[0] + ((ulong)(uint)array[1] << 32); - } - /// /// Calculate the long value of a BitArray /// diff --git a/RevolveUavcanTest/Tools/BitArrayToolsGetValueTests.cs b/RevolveUavcanTest/Tools/BitArrayToolsGetValueTests.cs index 988f5e7..44125cd 100644 --- a/RevolveUavcanTest/Tools/BitArrayToolsGetValueTests.cs +++ b/RevolveUavcanTest/Tools/BitArrayToolsGetValueTests.cs @@ -148,35 +148,5 @@ public static IEnumerable GetFloatAndDoubleInvalidData() yield return new object[] { new BitArray(42) }; yield return new object[] { new BitArray(69) }; } - - - [DataTestMethod] - [DynamicData(nameof(GetULongValidData), DynamicDataSourceType.Method)] - public void GetULongValidArgsTest(BitArray bitArray, ulong expectedResult) - { - var result = bitArray.GetULongFromBitArray(); - Assert.AreEqual(expectedResult, result); - } - - public static IEnumerable GetULongValidData() - { - yield return new object[] { new BitArray(BitConverter.GetBytes((ulong) 12)), (ulong) 12 }; - yield return new object[] { new BitArray(BitConverter.GetBytes((ulong) 17)), (ulong ) 17 }; - yield return new object[] { new BitArray(BitConverter.GetBytes((ulong) 128)), (ulong) 128 }; - yield return new object[] { new BitArray(BitConverter.GetBytes((ulong) 12_000)), (ulong) 12_000 }; - yield return new object[] { new BitArray(BitConverter.GetBytes((ulong) 3_000_000_000)), (ulong) 3_000_000_000 }; - } - - [TestMethod] - [DynamicData(nameof(GetULongInvalidData), DynamicDataSourceType.Method)] - public void GetULongInvalidArgsTest(BitArray bitArray) - { - Assert.ThrowsException(() => bitArray.GetULongFromBitArray()); - } - - public static IEnumerable GetULongInvalidData() - { - yield return new object[] { new BitArray(69) }; - } } }