void WriteNormalBits() { BitStringWriter writer = new BitStringWriter(); for (int i = 0; i < m_bits.Count; i++) { writer.Write((uint)Math.Min((int)m_bits[i], MaxNormalValue), NormalBits); } writer.Flush(); m_result.AddRange(writer.Bytes); }
void WriteExceptionBits() { BitStringWriter writer = new BitStringWriter(); for (int i = 0; i < m_bits.Count; i++) { if (m_bits[i] >= MaxNormalValue) { writer.Write((uint)((int)m_bits[i] - MaxNormalValue), ExceptionBits); } } writer.Flush(); m_result.AddRange(writer.Bytes); }
public void TestTwoBytesSplit() { BitStringWriter writer = new BitStringWriter(); writer.Write(0, 3); writer.Write(1, 3); writer.Write(2, 3); writer.Write(3, 3); writer.Flush(); byte[] expected = { unchecked((byte)-120), unchecked((byte)6) }; byte[] actual = Base64.ByteEncoding.GetBytes(writer.Value); CollectionAssert.AreEqual(actual, expected); }
public void TestOneByte() { BitStringWriter writer = new BitStringWriter(); writer.Write(0, 2); writer.Write(1, 2); writer.Write(2, 2); writer.Write(3, 2); writer.Flush(); byte[] expected = { unchecked((byte)-28) }; byte[] actual = Base64.ByteEncoding.GetBytes(writer.Value); CollectionAssert.AreEqual(actual, expected); }