public void ReflectBits_UInt32_Works() { UInt32 value = 0x9df3404c; var expectedValues = new Dictionary <int, UInt32>() { { 1, 0x0000 }, { 17, 0x00006405 }, { 2, 0x0000 }, { 18, 0x0000c80b }, { 3, 0x0001 }, { 19, 0x00019016 }, { 4, 0x0003 }, { 20, 0x0003202c }, { 5, 0x0006 }, { 21, 0x00064059 }, { 6, 0x000c }, { 22, 0x000c80b3 }, { 7, 0x0019 }, { 23, 0x00190167 }, { 8, 0x0032 }, { 24, 0x003202cf }, { 9, 0x0064 }, { 25, 0x0064059f }, { 10, 0x00c8 }, { 26, 0x00c80b3e }, { 11, 0x0190 }, { 27, 0x0190167d }, { 12, 0x0320 }, { 28, 0x03202cfb }, { 13, 0x0640 }, { 29, 0x064059f7 }, { 14, 0x0c80 }, { 30, 0x0c80b3ee }, { 15, 0x1901 }, { 31, 0x190167dc }, { 16, 0x3202 }, { 32, 0x3202cfb9 }, }; foreach (var expectedValue in expectedValues) { Assert.Equal( expectedValue.Value, value.ReflectBits(expectedValue.Key)); } }
public void ReflectBits_UInt32_InvalidBitLength_Throws() { UInt32 value = 0; foreach (var invalidBitLength in new[] { int.MinValue, short.MinValue, -1, 0, 33, short.MaxValue, int.MaxValue }) { Assert.Equal("bitLength", Assert.Throws <ArgumentOutOfRangeException>(() => value.ReflectBits(invalidBitLength)) .ParamName); } }