Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
prozolic committed Oct 5, 2024
1 parent 947daab commit de5b952
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tests/Utf8StringSplitter.Tests/Utf8SplitterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,15 +1117,17 @@ public void SplitAnyWithTrimEntriesAndRemoveEmptyEntriesTest2()
[Fact]
public void SplitAnyWithUtf8SeparatorOptionsTest()
{
var source = new byte[] { 227, 129, 130, 227, 129, 132, 227, 129, 134, 227, 129, 136, 227, 129, 134, 227, 129, 138 }; //あいうえうお
var separator = new byte[] { 227, 129, 134 }; //う
{
var expected = new List<byte[]>()
{
"あい"u8.ToArray(),
""u8.ToArray(),
""u8.ToArray(),
new byte[] { 227, 129, 130, 227, 129, 132 }, // あい
new byte[] { 227, 129, 136}, // え
new byte[] { 227, 129, 138}, // お
};
var index = 0;
foreach (var s in Utf8Splitter.SplitAny("あいうえうお"u8, ""u8))
foreach (var s in Utf8Splitter.SplitAny(source, separator))
{
Console.WriteLine($"{Encoding.UTF8.GetString(s.ToArray())}");
s.SequenceEqual(expected[index++]).Should().BeTrue();
Expand All @@ -1136,12 +1138,12 @@ public void SplitAnyWithUtf8SeparatorOptionsTest()
{
var expected = new List<byte[]>()
{
"あい"u8.ToArray(),
""u8.ToArray(),
""u8.ToArray(),
new byte[] { 227, 129, 130, 227, 129, 132 },
new byte[] { 227, 129, 136},
new byte[] { 227, 129, 138},
};
var index = 0;
foreach (var s in Utf8Splitter.SplitAny("あいうえうお"u8, ""u8, separatorOptions:Utf8StringSeparatorOptions.Utf8))
foreach (var s in Utf8Splitter.SplitAny(source, separator, separatorOptions:Utf8StringSeparatorOptions.Utf8))
{
Console.WriteLine($"{Encoding.UTF8.GetString(s.ToArray())}");
s.SequenceEqual(expected[index++]).Should().BeTrue();
Expand All @@ -1154,13 +1156,13 @@ public void SplitAnyWithUtf8SeparatorOptionsTest()
[Fact]
public void SplitAnyWithBytesSeparatorOptionsTest()
{
var source = new byte[] { 227, 129, 130, 227, 129, 132, 227, 129, 134, 227, 129, 136, 227, 129, 134, 227, 129, 138 }; //あいうえうお
var separator = new byte[] { 227, 129, 134 }; //う
{
var actual = new List<byte[]>();
var expected = new List<byte[]>();
expected.AddRange([[], [], [130], [], [132], [], [], [], [], [136], [], [], [], [], [138]]);

var ss = "あいうえうお"u8.ToArray();
foreach (var s in Utf8Splitter.SplitAny("あいうえうお"u8, ""u8, separatorOptions: Utf8StringSeparatorOptions.Bytes))
foreach (var s in Utf8Splitter.SplitAny(source, separator, separatorOptions: Utf8StringSeparatorOptions.Bytes))
{
Console.WriteLine($"{Encoding.UTF8.GetString(s.ToArray())}");
actual.Add(s.ToArray());
Expand All @@ -1178,7 +1180,7 @@ public void SplitAnyWithBytesSeparatorOptionsTest()
};
var index = 0;

foreach (var s in Utf8Splitter.SplitAny("あいうえうお"u8, ""u8, splitOptions: Utf8StringSplitOptions.RemoveEmptyEntries, separatorOptions: Utf8StringSeparatorOptions.Bytes))
foreach (var s in Utf8Splitter.SplitAny(source, separator, splitOptions: Utf8StringSplitOptions.RemoveEmptyEntries, separatorOptions: Utf8StringSeparatorOptions.Bytes))
{
Console.WriteLine($"{Encoding.UTF8.GetString(s.ToArray())}");
s.SequenceEqual([expected[index++]]).Should().BeTrue();
Expand Down

0 comments on commit de5b952

Please sign in to comment.