public void BitField32_Throws() { var test = new BitField32(); for (byte i = 0; i < 32; ++i) { Assert.DoesNotThrow(() => { test.GetBits(i, (byte)(32 - i)); }); } Assert.Throws <ArgumentException>(() => { test.GetBits(0, 33); }); Assert.Throws <ArgumentException>(() => { test.GetBits(1, 32); }); }
public void BitField32_Get_Set() { var test = new BitField32(); uint bits; bits = test.GetBits(0, 32); Assert.AreEqual(0x0, bits); test.SetBits(0, true); bits = test.GetBits(0, 32); Assert.AreEqual(0x1, bits); test.SetBits(0, true, 32); bits = test.GetBits(0, 32); Assert.AreEqual(0xffffffff, bits); Assert.IsTrue(test.TestAll(0, 32)); test.SetBits(0, false, 32); bits = test.GetBits(0, 32); Assert.AreEqual(0x0, bits); test.SetBits(15, true, 7); Assert.IsTrue(test.TestAll(15, 7)); test.SetBits(3, true, 3); Assert.IsTrue(test.TestAll(3, 3)); bits = test.GetBits(0, 32); Assert.AreEqual(0x3f8038, bits); bits = test.GetBits(0, 15); Assert.AreEqual(0x38, bits); Assert.IsFalse(test.TestNone(0, 32)); Assert.IsFalse(test.TestAll(0, 32)); Assert.IsTrue(test.TestAny(0, 32)); }