Skip to content

Commit

Permalink
add new reader test
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed May 16, 2024
1 parent 399c60c commit c771a9e
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions test/ReaderTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Text;
using Byter;
using Xunit;

namespace ByterTest;

public class ReaderTest
Expand All @@ -10,7 +12,9 @@ public class ReaderTest
private const float FLOAT_Z = 1024 * 6;
private const float FLOAT_W = 1024 * 8;

public ReaderTest() { }
public ReaderTest()
{
}

[Fact]
public void ReadByte()
Expand Down Expand Up @@ -279,7 +283,7 @@ public void ImplFloat3()
Assert.Equal(FLOAT_Y, result.Y);
Assert.Equal(FLOAT_Z, result.Z);
}

[Fact]
public void ImplFloat4()
{
Expand All @@ -290,4 +294,40 @@ public void ImplFloat4()
Assert.Equal(FLOAT_Z, result.Z);
Assert.Equal(FLOAT_W, result.W);
}
}

[Fact]
public void ReadFromEmptyBuffer()
{
Reader r = new Reader(Array.Empty<byte>());

Assert.True(r.Success);

_ = r.Read<string>(Encoding.ASCII);

Assert.False(r.Success);
}

[Fact]
public void ReadFromNullBuffer()
{
Reader r = new Reader(null);

Assert.True(r.Success);

_ = r.Read<string>(Encoding.ASCII);

Assert.False(r.Success);
}

[Fact]
public void ReadFromOneByteBuffer()
{
Reader r = new Reader([0]);

Assert.True(r.Success);

_ = r.Read<string>(Encoding.ASCII);

Assert.False(r.Success);
}
}

0 comments on commit c771a9e

Please sign in to comment.