Rename LSB/MSB to LE/BE

This commit is contained in:
Matt Nadareski
2024-11-18 10:30:55 -05:00
parent 8e3d204329
commit c5c8ce67ba
2 changed files with 16 additions and 16 deletions

View File

@@ -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);

View File

@@ -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;