-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bd1246
commit fa9be85
Showing
3 changed files
with
80 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
namespace Tests; | ||
|
||
using System.Text; | ||
using Split.Extensions; | ||
using Xunit; | ||
|
||
public class SplitTests | ||
{ | ||
static readonly string abcd = "abc𝚫"; | ||
static readonly string emoji = "👍🐶"; | ||
static readonly string efghi = "éfghi"; | ||
|
||
static string RandomString(int length) | ||
{ | ||
var b = new byte[length]; | ||
return Encoding.UTF8.GetString(b); | ||
} | ||
|
||
readonly Random rnd = new(); | ||
|
||
static readonly string[] testSeparators = ["", " ", ",", ", ", "🐶", "𝚫", "🌏👍", abcd, emoji, efghi, RandomString(4)]; | ||
|
||
static IEnumerable<string> TestStrings() | ||
{ | ||
yield return ""; | ||
yield return abcd; | ||
yield return emoji; | ||
yield return efghi; | ||
|
||
foreach (string sep in testSeparators) | ||
{ | ||
yield return sep; | ||
var center = abcd + sep + emoji + sep + efghi; | ||
yield return center; | ||
yield return sep + center; | ||
yield return center + sep; | ||
yield return sep + center + sep; | ||
yield return RandomString(15); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void Strings() | ||
{ | ||
foreach (string s in TestStrings()) | ||
{ | ||
foreach (var sep in testSeparators) | ||
{ | ||
var got = s.SplitOn(sep).ToList().Select(g => new string(g)); | ||
var expected = s.Split(sep); | ||
|
||
Assert.Equal(expected, got); | ||
} | ||
} | ||
} | ||
} |