Skip to content

Commit

Permalink
Merge pull request dotnet#1405 from KrzysztofCwalina/STEW
Browse files Browse the repository at this point in the history
Enabled some tests that were disabled before
  • Loading branch information
KrzysztofCwalina committed Apr 16, 2015
2 parents 70d9135 + 157f155 commit 6bcc9eb
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 37 deletions.
15 changes: 7 additions & 8 deletions src/System.Text.Encodings.Web/tests/HtmlEncoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@ public void Default_ReturnsSingletonInstance()
Assert.Same(encoder1, encoder2);
}

// TODO: fix xUnit escaping and then uncomment
//[Theory]
//[InlineData("<", "&lt;")]
//[InlineData(">", "&gt;")]
//[InlineData("&", "&amp;")]
//[InlineData("'", "&#x27;")]
//[InlineData("\"", "&quot;")]
//[InlineData("+", "&#x2B;")]
[Theory]
[InlineData("<", "&lt;")]
[InlineData(">", "&gt;")]
[InlineData("&", "&amp;")]
[InlineData("'", "&#x27;")]
[InlineData("\"", "&quot;")]
[InlineData("+", "&#x2B;")]
public void HtmlEncode_AllRangesAllowed_StillEncodesForbiddenChars_Simple(string input, string expected)
{
// Arrange
Expand Down
44 changes: 25 additions & 19 deletions src/System.Text.Encodings.Web/tests/JavaScriptStringEncoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,28 @@ public void Default_ReturnsSingletonInstance()
Assert.Same(encoder1, encoder2);
}

// TODO: fix xUnit escaping and then uncomment
//[Theory]
//[InlineData("<", @"\u003C")]
//[InlineData(">", @"\u003E")]
//[InlineData("&", @"\u0026")]
//[InlineData("'", @"\u0027")]
//[InlineData("\"", @"\u0022")]
//[InlineData("+", @"\u002B")]
//[InlineData("\\", @"\\")]
//[InlineData("/", @"\/")]
//[InlineData("\b", @"\b")]
//[InlineData("\f", @"\f")]
//[InlineData("\n", @"\n")]
//[InlineData("\t", @"\t")]
//[InlineData("\r", @"\r")]
[Fact]
public void JavaScriptStringEncode_AllRangesAllowed_StillEncodesForbiddenChars_Simple_Escaping() {
// The following two calls could be simply InlineData to the Theory below
// Unfortunatelly, the xUnit logger fails to escape the inputs when logging the test results,
// and so the suite fails despite all tests passing.
// TODO: I will try to fix it in xUnit, but for now this is a workaround to enable these tests.
JavaScriptStringEncode_AllRangesAllowed_StillEncodesForbiddenChars_Simple("\b", @"\b");
JavaScriptStringEncode_AllRangesAllowed_StillEncodesForbiddenChars_Simple("\f", @"\f");
}

[Theory]
[InlineData("<", @"\u003C")]
[InlineData(">", @"\u003E")]
[InlineData("&", @"\u0026")]
[InlineData("'", @"\u0027")]
[InlineData("\"", @"\u0022")]
[InlineData("+", @"\u002B")]
[InlineData("\\", @"\\")]
[InlineData("/", @"\/")]
[InlineData("\n", @"\n")]
[InlineData("\t", @"\t")]
[InlineData("\r", @"\r")]
public void JavaScriptStringEncode_AllRangesAllowed_StillEncodesForbiddenChars_Simple(string input, string expected)
{
// Arrange
Expand Down Expand Up @@ -281,10 +288,9 @@ public void JavaScriptStringEncode_StringSubstring()
Assert.Equal(@"lo\u002Bwo", output.ToString());
}

// TODO: fix xUnit escaping and then uncomment
//[Theory]
//[InlineData("\"", @"\u0022")]
//[InlineData("'", @"\u0027")]
[Theory]
[InlineData("\"", @"\u0022")]
[InlineData("'", @"\u0027")]
public void JavaScriptStringEncode_Quotes(string input, string expected)
{
// Per the design document, we provide additional defense-in-depth
Expand Down
20 changes: 10 additions & 10 deletions src/System.Text.Encodings.Web/tests/UnicodeHelpersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ public void GetDefinedCharacterBitmap_ReturnsSingletonInstance()
Assert.Same(retVal1, retVal2);
}

// TODO: fix xUnit escaping and then uncomment
//[Theory]
//[InlineData(1, "a", (int)'a')] // normal BMP char, end of string
//[InlineData(2, "ab", (int)'a')] // normal BMP char, not end of string
//[InlineData(3, "\uDFFF", UnicodeReplacementChar)] // trailing surrogate, end of string
//[InlineData(4, "\uDFFFx", UnicodeReplacementChar)] // trailing surrogate, not end of string
//[InlineData(5, "\uD800", UnicodeReplacementChar)] // leading surrogate, end of string
//[InlineData(6, "\uD800x", UnicodeReplacementChar)] // leading surrogate, not end of string, followed by non-surrogate
//[InlineData(7, "\uD800\uD800", UnicodeReplacementChar)] // leading surrogate, not end of string, followed by leading surrogate
//[InlineData(8, "\uD800\uDFFF", 0x103FF)] // leading surrogate, not end of string, followed by trailing surrogate

[Theory]
[InlineData(1, "a", (int)'a')] // normal BMP char, end of string
[InlineData(2, "ab", (int)'a')] // normal BMP char, not end of string
[InlineData(3, "\uDFFF", UnicodeReplacementChar)] // trailing surrogate, end of string
[InlineData(4, "\uDFFFx", UnicodeReplacementChar)] // trailing surrogate, not end of string
[InlineData(5, "\uD800", UnicodeReplacementChar)] // leading surrogate, end of string
[InlineData(6, "\uD800x", UnicodeReplacementChar)] // leading surrogate, not end of string, followed by non-surrogate
[InlineData(7, "\uD800\uD800", UnicodeReplacementChar)] // leading surrogate, not end of string, followed by leading surrogate
[InlineData(8, "\uD800\uDFFF", 0x103FF)] // leading surrogate, not end of string, followed by trailing surrogate
public void GetScalarValueFromUtf16(int unused, string input, int expectedResult)
{
// The 'unused' parameter exists because the xunit runner can't distinguish
Expand Down

0 comments on commit 6bcc9eb

Please sign in to comment.