mirror of
https://github.com/SabreTools/SabreTools.IO.git
synced 2026-02-04 05:36:05 +00:00
Remove some nonsensical endian methods
This commit is contained in:
@@ -41,17 +41,6 @@ namespace SabreTools.IO.Test.Extensions
|
||||
Assert.True(arr.SequenceEqual(_bytes.Take(4)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadByteArrayBigEndianTest()
|
||||
{
|
||||
byte[] arr = new byte[4];
|
||||
var stream = new MemoryStream(_bytes);
|
||||
var br = new BinaryReader(stream);
|
||||
int read = br.ReadBigEndian(arr, 0, 4);
|
||||
Assert.Equal(4, read);
|
||||
Assert.True(arr.SequenceEqual(_bytes.Take(4).Reverse()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadCharArrayTest()
|
||||
{
|
||||
@@ -63,17 +52,6 @@ namespace SabreTools.IO.Test.Extensions
|
||||
Assert.True(arr.SequenceEqual(_bytes.Take(4).Select(b => (char)b)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadCharArrayBigEndianTest()
|
||||
{
|
||||
char[] arr = new char[4];
|
||||
var stream = new MemoryStream(_bytes);
|
||||
var br = new BinaryReader(stream);
|
||||
int read = br.ReadBigEndian(arr, 0, 4);
|
||||
Assert.Equal(4, read);
|
||||
Assert.True(arr.SequenceEqual(_bytes.Take(4).Select(b => (char)b).Reverse()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadByteTest()
|
||||
{
|
||||
@@ -94,17 +72,6 @@ namespace SabreTools.IO.Test.Extensions
|
||||
Assert.True(read.SequenceEqual(_bytes.Take(length)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadBytesBigEndianTest()
|
||||
{
|
||||
var stream = new MemoryStream(_bytes);
|
||||
var br = new BinaryReader(stream);
|
||||
int length = 4;
|
||||
byte[] read = br.ReadBytesBigEndian(length);
|
||||
Assert.Equal(length, read.Length);
|
||||
Assert.True(read.SequenceEqual(_bytes.Take(length).Reverse()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadCharsTest()
|
||||
{
|
||||
@@ -116,17 +83,6 @@ namespace SabreTools.IO.Test.Extensions
|
||||
Assert.True(read.SequenceEqual(_bytes.Take(length).Select(b => (char)b)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadCharsBigEndianTest()
|
||||
{
|
||||
var stream = new MemoryStream(_bytes);
|
||||
var br = new BinaryReader(stream);
|
||||
int length = 4;
|
||||
char[] read = br.ReadCharsBigEndian(length);
|
||||
Assert.Equal(length, read.Length);
|
||||
Assert.True(read.SequenceEqual(_bytes.Take(length).Select(b => (char)b).Reverse()));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadSByteTest()
|
||||
{
|
||||
|
||||
@@ -17,42 +17,6 @@ namespace SabreTools.IO.Extensions
|
||||
{
|
||||
#region Exact Read
|
||||
|
||||
/// <inheritdoc cref="BinaryReader.Read(byte[], int, int)"/>
|
||||
/// <remarks>Reads in big-endian format</remarks>
|
||||
public static int ReadBigEndian(this BinaryReader reader, byte[] buffer, int index, int count)
|
||||
{
|
||||
int retval = reader.Read(buffer, index, count);
|
||||
Array.Reverse(buffer);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="BinaryReader.Read(char[], int, int)"/>
|
||||
/// <remarks>Reads in big-endian format</remarks>
|
||||
public static int ReadBigEndian(this BinaryReader reader, char[] buffer, int index, int count)
|
||||
{
|
||||
int retval = reader.Read(buffer, index, count);
|
||||
Array.Reverse(buffer);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="BinaryReader.ReadBytes(int)"/>
|
||||
/// <remarks>Reads in big-endian format</remarks>
|
||||
public static byte[] ReadBytesBigEndian(this BinaryReader reader, int count)
|
||||
{
|
||||
byte[] buffer = reader.ReadBytes(count);
|
||||
Array.Reverse(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="BinaryReader.ReadChars(int)"/>
|
||||
/// <remarks>Reads in big-endian format</remarks>
|
||||
public static char[] ReadCharsBigEndian(this BinaryReader reader, int count)
|
||||
{
|
||||
char[] buffer = reader.ReadChars(count);
|
||||
Array.Reverse(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="BinaryReader.ReadInt16"/>
|
||||
/// <remarks>Reads in big-endian format</remarks>
|
||||
public static short ReadInt16BigEndian(this BinaryReader reader)
|
||||
|
||||
@@ -37,17 +37,6 @@ namespace SabreTools.IO.Extensions
|
||||
public static byte[] ReadBytes(this byte[] content, ref int offset, int count)
|
||||
=> ReadExactlyToBuffer(content, ref offset, count);
|
||||
|
||||
/// <summary>
|
||||
/// Read a UInt8[] and increment the pointer to an array
|
||||
/// </summary>
|
||||
/// <remarks>Reads in big-endian format</remarks>
|
||||
public static byte[] ReadBytesBigEndian(this byte[] content, ref int offset, int count)
|
||||
{
|
||||
byte[] buffer = ReadExactlyToBuffer(content, ref offset, count);
|
||||
Array.Reverse(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read an Int8 and increment the pointer to an array
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user