public void ReflectBits_UInt64_Works() { UInt64 value = 0xf2faab56cb0b277f; var expectedValues = new Dictionary <int, UInt64>() { { 1, 0x0001 }, { 17, 0x0001fdc9 }, { 33, 0x0001fdc9a1a6 }, { 49, 0x0001fdc9a1a6d5aa }, { 2, 0x0003 }, { 18, 0x0003fb93 }, { 34, 0x0003fb93434d }, { 50, 0x0003fb93434dab55 }, { 3, 0x0007 }, { 19, 0x0007f726 }, { 35, 0x0007f726869b }, { 51, 0x0007f726869b56aa }, { 4, 0x000f }, { 20, 0x000fee4d }, { 36, 0x000fee4d0d36 }, { 52, 0x000fee4d0d36ad55 }, { 5, 0x001f }, { 21, 0x001fdc9a }, { 37, 0x001fdc9a1a6d }, { 53, 0x001fdc9a1a6d5aab }, { 6, 0x003f }, { 22, 0x003fb934 }, { 38, 0x003fb93434da }, { 54, 0x003fb93434dab557 }, { 7, 0x007f }, { 23, 0x007f7268 }, { 39, 0x007f726869b5 }, { 55, 0x007f726869b56aaf }, { 8, 0x00fe }, { 24, 0x00fee4d0 }, { 40, 0x00fee4d0d36a }, { 56, 0x00fee4d0d36ad55f }, { 9, 0x01fd }, { 25, 0x01fdc9a1 }, { 41, 0x01fdc9a1a6d5 }, { 57, 0x01fdc9a1a6d5aabe }, { 10, 0x03fb }, { 26, 0x03fb9343 }, { 42, 0x03fb93434dab }, { 58, 0x03fb93434dab557d }, { 11, 0x07f7 }, { 27, 0x07f72686 }, { 43, 0x07f726869b56 }, { 59, 0x07f726869b56aafa }, { 12, 0x0fee }, { 28, 0x0fee4d0d }, { 44, 0x0fee4d0d36ad }, { 60, 0x0fee4d0d36ad55f4 }, { 13, 0x1fdc }, { 29, 0x1fdc9a1a }, { 45, 0x1fdc9a1a6d5a }, { 61, 0x1fdc9a1a6d5aabe9 }, { 14, 0x3fb9 }, { 30, 0x3fb93434 }, { 46, 0x3fb93434dab5 }, { 62, 0x3fb93434dab557d3 }, { 15, 0x7f72 }, { 31, 0x7f726869 }, { 47, 0x7f726869b56a }, { 63, 0x7f726869b56aafa7 }, { 16, 0xfee4 }, { 32, 0xfee4d0d3 }, { 48, 0xfee4d0d36ad5 }, { 64, 0xfee4d0d36ad55f4f }, }; foreach (var expectedValue in expectedValues) { Assert.Equal( expectedValue.Value, value.ReflectBits(expectedValue.Key)); } }
public void ReflectBits_UInt64_InvalidBitLength_Throws() { UInt64 value = 0; foreach (var invalidBitLength in new[] { int.MinValue, short.MinValue, -1, 0, 65, short.MaxValue, int.MaxValue }) { Assert.Equal("bitLength", Assert.Throws <ArgumentOutOfRangeException>(() => value.ReflectBits(invalidBitLength)) .ParamName); } }