Core + binary enumerator
This commit is contained in:
commit
0cbce3c165
8 changed files with 192 additions and 0 deletions
42
test/Nyanbyte.Sysnya.CoreTests/Binary/BinaryReaderTests.cs
Normal file
42
test/Nyanbyte.Sysnya.CoreTests/Binary/BinaryReaderTests.cs
Normal file
|
@ -0,0 +1,42 @@
|
|||
using Nyanbyte.Sysnya.Binary;
|
||||
|
||||
namespace Nyanbyte.Sysnya.CoreTests.Binary;
|
||||
|
||||
public class BinaryReaderTests
|
||||
{
|
||||
[Fact]
|
||||
public void BinaryEnumeratorReadTestsBigEndian()
|
||||
{
|
||||
// Given
|
||||
byte[] memory = { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
|
||||
BinaryEnumerator reader = new(memory, true);
|
||||
|
||||
// When
|
||||
reader.ReadInt32(out int valA);
|
||||
reader.ReadInt32(out int valB);
|
||||
reader.ReadInt64(out long valC);
|
||||
|
||||
// Then
|
||||
Assert.Equal(0x1, valA);
|
||||
Assert.Equal(0x1000000, valB);
|
||||
Assert.Equal(0x1, valC);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BinaryEnumeratorReadTestsLittleEndian()
|
||||
{
|
||||
// Given
|
||||
byte[] memory = { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
|
||||
BinaryEnumerator reader = new(memory, false);
|
||||
|
||||
// When
|
||||
reader.ReadInt32(out int valA);
|
||||
reader.ReadInt32(out int valB);
|
||||
reader.ReadInt64(out long valC);
|
||||
|
||||
// Then
|
||||
Assert.Equal(0x1000000, valA);
|
||||
Assert.Equal(0x1, valB);
|
||||
Assert.Equal(0x100000000000000, valC);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue