mirror of
https://github.com/SabreTools/SabreTools.IO.git
synced 2026-09-24 15:46:21 +00:00
Rename LSB/MSB to LE/BE
This commit is contained in:
@@ -19,44 +19,44 @@ namespace SabreTools.IO.Test.Streams
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadSingleBitLSBTest()
|
||||
public void ReadSingleBitLETest()
|
||||
{
|
||||
byte[] data = [0b01010101];
|
||||
var stream = new ReadOnlyBitStream(new MemoryStream(data));
|
||||
byte? bit = stream.ReadBitLSB();
|
||||
byte? bit = stream.ReadBitLE();
|
||||
Assert.NotNull(bit);
|
||||
Assert.Equal((byte)0b00000000, bit);
|
||||
Assert.Equal(1, stream.Position);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadSingleBitMSBTest()
|
||||
public void ReadSingleBitBETest()
|
||||
{
|
||||
byte[] data = [0b01010101];
|
||||
var stream = new ReadOnlyBitStream(new MemoryStream(data));
|
||||
byte? bit = stream.ReadBitMSB();
|
||||
byte? bit = stream.ReadBitBE();
|
||||
Assert.NotNull(bit);
|
||||
Assert.Equal((byte)0b00000001, bit);
|
||||
Assert.Equal(1, stream.Position);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadBitsLSBTest()
|
||||
public void ReadBitsLETest()
|
||||
{
|
||||
byte[] data = [0b01010101, 0b01010101, 0b01010101, 0b01010101];
|
||||
var stream = new ReadOnlyBitStream(new MemoryStream(data));
|
||||
uint? bits = stream.ReadBitsLSB(4);
|
||||
uint? bits = stream.ReadBitsLE(4);
|
||||
Assert.NotNull(bits);
|
||||
Assert.Equal((byte)0b00001010, bits); // Transcribed to big-endian
|
||||
Assert.Equal(1, stream.Position);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadBitsMSBTest()
|
||||
public void ReadBitsBETest()
|
||||
{
|
||||
byte[] data = [0b01010101, 0b01010101, 0b01010101, 0b01010101];
|
||||
var stream = new ReadOnlyBitStream(new MemoryStream(data));
|
||||
uint? bits = stream.ReadBitsMSB(4);
|
||||
uint? bits = stream.ReadBitsBE(4);
|
||||
Assert.NotNull(bits);
|
||||
Assert.Equal((byte)0b00001010, bits);
|
||||
Assert.Equal(1, stream.Position);
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace SabreTools.IO.Streams
|
||||
/// Read a single bit little-endian, if possible
|
||||
/// </summary>
|
||||
/// <returns>The next bit encoded in a byte, null on error or end of stream</returns>
|
||||
public byte? ReadBitLSB()
|
||||
public byte? ReadBitLE()
|
||||
{
|
||||
// If we reached the end of the stream
|
||||
if (_source.Position >= _source.Length)
|
||||
@@ -91,7 +91,7 @@ namespace SabreTools.IO.Streams
|
||||
/// Read a single bit big-endian, if possible
|
||||
/// </summary>
|
||||
/// <returns>The next bit encoded in a byte, null on error or end of stream</returns>
|
||||
public byte? ReadBitMSB()
|
||||
public byte? ReadBitBE()
|
||||
{
|
||||
// If we reached the end of the stream
|
||||
if (_source.Position >= _source.Length)
|
||||
@@ -122,16 +122,16 @@ namespace SabreTools.IO.Streams
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a multiple bits in LSB, if possible
|
||||
/// Read a multiple bits in little-endian, if possible
|
||||
/// </summary>
|
||||
/// <returns>The next bits encoded in a UInt32, null on error or end of stream</returns>
|
||||
public uint? ReadBitsLSB(int bits)
|
||||
public uint? ReadBitsLE(int bits)
|
||||
{
|
||||
uint value = 0;
|
||||
for (int i = 0; i < bits; i++)
|
||||
{
|
||||
// Read the next bit
|
||||
byte? bitValue = ReadBitLSB();
|
||||
byte? bitValue = ReadBitLE();
|
||||
if (bitValue == null)
|
||||
return null;
|
||||
|
||||
@@ -143,16 +143,16 @@ namespace SabreTools.IO.Streams
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read a multiple bits in MSB, if possible
|
||||
/// Read a multiple bits in big-endian, if possible
|
||||
/// </summary>
|
||||
/// <returns>The next bits encoded in a UInt32, null on error or end of stream</returns>
|
||||
public uint? ReadBitsMSB(int bits)
|
||||
public uint? ReadBitsBE(int bits)
|
||||
{
|
||||
uint value = 0;
|
||||
for (int i = 0; i < bits; i++)
|
||||
{
|
||||
// Read the next bit
|
||||
byte? bitValue = ReadBitMSB();
|
||||
byte? bitValue = ReadBitBE();
|
||||
if (bitValue == null)
|
||||
return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user