Skip to content

Commit

Permalink
Add a few IdnMapping tests (dotnet/corefx#28797)
Browse files Browse the repository at this point in the history
Validate that we get the same string object back when we expect to.

Commit migrated from dotnet/corefx@b3ba359
  • Loading branch information
stephentoub authored Apr 5, 2018
1 parent 5c05dbf commit d468d43
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ public void GetAscii(string unicode, int index, int count, string expected)
Assert.Equal(expected, new IdnMapping().GetAscii(unicode, index, count));
}

[SkipOnTargetFramework(~TargetFrameworkMonikers.Netcoreapp, "Optimization in .NET Core")]
[Theory]
[InlineData("www.microsoft.com")]
[InlineData("bing.com")]
public void GetAscii_NoTranslationNeeded_ResultIsSameObjectAsInput(string input)
{
Assert.Same(input, new IdnMapping().GetAscii(input));
Assert.NotSame(input, new IdnMapping().GetAscii(input.Substring(1)));
Assert.NotSame(input, new IdnMapping().GetAscii(input.Substring(0, input.Length - 1)));
}

[Fact]
public void TestGetAsciiWithDot()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public void GetUnicode(string ascii, int index, int count, string expected)
Assert.Equal(expected, new IdnMapping().GetUnicode(ascii, index, count));
}

[SkipOnTargetFramework(~TargetFrameworkMonikers.Netcoreapp, "Optimization in .NET Core")]
[Theory]
[InlineData("www.microsoft.com")]
[InlineData("bing.com")]
public void GetUnicode_NoTranslationNeeded_ResultIsSameObjectAsInput(string input)
{
Assert.Same(input, new IdnMapping().GetUnicode(input));
Assert.NotSame(input, new IdnMapping().GetUnicode(input.Substring(1)));
Assert.NotSame(input, new IdnMapping().GetUnicode(input.Substring(0, input.Length - 1)));
}

public static IEnumerable<object[]> GetUnicode_Invalid_TestData()
{
// Ascii is null
Expand Down

0 comments on commit d468d43

Please sign in to comment.