public void GetValue() { var readState = new RecordReadState(); var type = new SqlBit(readState, CompressionContext.NoCompression); // No bytes read - length is one Assert.AreEqual(1, type.FixedLength); // Load byte and check length is 0 readState.LoadBitByte(0xD2); Assert.AreEqual(0, type.FixedLength); Assert.IsFalse((bool)type.GetValue(new byte[0])); Assert.IsTrue((bool)type.GetValue(new byte[0])); Assert.IsFalse((bool)type.GetValue(new byte[0])); Assert.IsFalse((bool)type.GetValue(new byte[0])); Assert.IsTrue((bool)type.GetValue(new byte[0])); Assert.IsFalse((bool)type.GetValue(new byte[0])); Assert.IsTrue((bool)type.GetValue(new byte[0])); // One bit left - length should still be 0 Assert.AreEqual(0, type.FixedLength); Assert.IsTrue((bool)type.GetValue(new byte[0])); // All bits consumed - length should be 1 Assert.AreEqual(1, type.FixedLength); }
public void General() { var state = new RecordReadState(); // No bits available Assert.IsTrue(state.AllBitsConsumed); state.LoadBitByte(0xD2); // 11010010 // Bits available Assert.IsFalse(state.AllBitsConsumed); // Reading bit values Assert.IsFalse(state.GetNextBit()); Assert.IsTrue(state.GetNextBit()); Assert.IsFalse(state.GetNextBit()); Assert.IsFalse(state.GetNextBit()); Assert.IsTrue(state.GetNextBit()); Assert.IsFalse(state.GetNextBit()); Assert.IsTrue(state.GetNextBit()); // One bit left Assert.IsFalse(state.AllBitsConsumed); Assert.IsTrue(state.GetNextBit()); // Bits exhausted, ready for next byte Assert.IsTrue(state.AllBitsConsumed); }