public void Int() { var real_bytes = BitConverter.GetBytes(12345678); Assert.AreEqual(12345678, PointerCastHelper.BytesToInt(real_bytes, 0), "No se convirtió el puntero correctamente"); Assert.AreEqual(real_bytes[0], PointerCastHelper.IntToBytes(12345678)[0], "No se convirtió a un array de bytes correctamente"); Assert.AreEqual(real_bytes[1], PointerCastHelper.IntToBytes(12345678)[1], "No se convirtió a un array de bytes correctamente"); Assert.AreEqual(real_bytes[2], PointerCastHelper.IntToBytes(12345678)[2], "No se convirtió a un array de bytes correctamente"); Assert.AreEqual(real_bytes[3], PointerCastHelper.IntToBytes(12345678)[3], "No se convirtió a un array de bytes correctamente"); }
public static byte[] SerializeHeader(int record_length, bool deleted = false) { byte[] header = new byte[5]; PointerCastHelper.IntToBytes(record_length).CopyTo(header, 0); if (deleted) { header[4] = 0x01; } return(header); }