public void RoundTripCompactBools() { var objA = Helpers.RandomFill <CompactBoolsExample>(); var bytes = BitPack <CompactBoolsExample> .ToBytes(objA); var objB = BitPack <CompactBoolsExample> .FromBytes(bytes); Helpers.BitPackPropertiesAreEqual(objA, objB, true); }
public void RoundTripCompactBoolsWithOffsets() { var totalBytes = BitPack <AllTypesExample> .TotalBytes; var offset = ThreadRandom.Next(totalBytes, totalBytes * 2); var bytes = new byte[offset + totalBytes]; var objA = Helpers.RandomFill <CompactBoolsExample>(); BitPack <CompactBoolsExample> .WriteToByteArray(objA, bytes, offset); // ensure that nothing was written before the offset for (var i = 0; i < offset; i++) { if (bytes[i] != 0) { throw new Exception("Bytes were written before the offset."); } } var objB = BitPack <CompactBoolsExample> .FromBytes(bytes, offset); Helpers.BitPackPropertiesAreEqual(objA, objB, true); }