Skip to content

Commit

Permalink
create test for ByteExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
alec1o committed Apr 29, 2024
1 parent 341d66b commit 4d9c64b
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/extension/ByteExtensionTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
using System.Text;
using Byter;
using Xunit;

namespace ByterTest.extension;

public class ByteExtensionTest
{

private const string BaseText = "Byter is a bytes serializer!";

[Fact]
public void GetString()
{
byte[] defBytes = BaseText.GetBytes(StringExtension.Default);
byte[] utf8Bytes = BaseText.GetBytes(Encoding.UTF8);
byte[] utf16Bytes = BaseText.GetBytes(Encoding.Unicode);
byte[] utf32Bytes = BaseText.GetBytes(Encoding.UTF32);

Assert.Equal(BaseText, defBytes.GetString());
Assert.Equal(BaseText, utf8Bytes.GetString(Encoding.UTF8));
Assert.Equal(BaseText, utf16Bytes.GetString(Encoding.Unicode));
Assert.Equal(BaseText, utf32Bytes.GetString(Encoding.UTF32));

Assert.NotEqual(BaseText, utf16Bytes.GetString(Encoding.UTF8));
Assert.NotEqual(BaseText, utf32Bytes.GetString(Encoding.Unicode));
Assert.NotEqual(BaseText, utf8Bytes.GetString(Encoding.UTF32));
}
}

0 comments on commit 4d9c64b

Please sign in to comment.