mirror of
https://github.com/SabreTools/SabreTools.IO.git
synced 2026-09-24 15:46:21 +00:00
Start parting out IO.Extensions a bit more
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace SabreTools.IO.Extensions.Test
|
||||
@@ -17,52 +16,6 @@ namespace SabreTools.IO.Extensions.Test
|
||||
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ReadNullTerminatedStringTest()
|
||||
{
|
||||
// Encoding.ASCII
|
||||
int offset = 0;
|
||||
byte[] bytes = [0x41, 0x42, 0x43, 0x00];
|
||||
string? actual = bytes.ReadNullTerminatedString(ref offset, Encoding.ASCII);
|
||||
Assert.Equal("ABC", actual);
|
||||
|
||||
// Encoding.Latin1
|
||||
offset = 0;
|
||||
bytes = [0x41, 0x42, 0x43, 0x00];
|
||||
actual = bytes.ReadNullTerminatedString(ref offset, Encoding.Latin1);
|
||||
Assert.Equal("ABC", actual);
|
||||
|
||||
// Encoding.UTF8
|
||||
offset = 0;
|
||||
bytes = [0x41, 0x42, 0x43, 0x00];
|
||||
actual = bytes.ReadNullTerminatedString(ref offset, Encoding.UTF8);
|
||||
Assert.Equal("ABC", actual);
|
||||
|
||||
// Encoding.Unicode
|
||||
offset = 0;
|
||||
bytes = [0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x00, 0x00];
|
||||
actual = bytes.ReadNullTerminatedString(ref offset, Encoding.Unicode);
|
||||
Assert.Equal("ABC", actual);
|
||||
|
||||
// Encoding.BigEndianUnicode
|
||||
offset = 0;
|
||||
bytes = [0x00, 0x41, 0x00, 0x42, 0x00, 0x43, 0x00, 0x00];
|
||||
actual = bytes.ReadNullTerminatedString(ref offset, Encoding.BigEndianUnicode);
|
||||
Assert.Equal("ABC", actual);
|
||||
|
||||
// Encoding.UTF32
|
||||
offset = 0;
|
||||
bytes = [0x41, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
|
||||
actual = bytes.ReadNullTerminatedString(ref offset, Encoding.UTF32);
|
||||
Assert.Equal("ABC", actual);
|
||||
|
||||
// Encoding.Latin1
|
||||
offset = 0;
|
||||
bytes = [0x41, 0x42, 0x43, 0x00];
|
||||
actual = bytes.ReadNullTerminatedString(ref offset, Encoding.Latin1);
|
||||
Assert.Equal("ABC", actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ReadTypeTest()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user