Skip to content

Commit

Permalink
Add syntax normalizer tests for UTF8 String Literals. (#60269)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyTs committed Mar 21, 2022
1 parent 9356f33 commit 428d3b3
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxNormalizerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,84 @@ public void TestNormalizeSwitchExpressionRawStrings()
);
}

[Fact]
public void TestNormalizeSwitchExpressionRawStringsUTF8_01()
{
TestNormalizeStatement(
@"var x = (int)1 switch { 1 => """"""one""""""u8, 2 => """"""two""""""U8, 3 => """"""three""""""u8, {} => """""">= 4""""""U8 };",
@"var x = (int)1 switch
{
1 => """"""one""""""u8,
2 => """"""two""""""U8,
3 => """"""three""""""u8,
{ } => """""">= 4""""""U8
};".NormalizeLineEndings()
);
}

[ConditionalFact(typeof(WindowsOnly))]
public void TestNormalizeSwitchExpressionRawStringsMultiline()
{
TestNormalizeStatement(
@"var x = (int)1 switch { 1 => """"""
one
"""""", 2 =>
""""""
two
"""""" };",
@"var x = (int)1 switch
{
1 => """"""
one
"""""",
2 => """"""
two
""""""
};".NormalizeLineEndings()
);
}

[ConditionalFact(typeof(WindowsOnly))]
public void TestNormalizeSwitchExpressionRawStringsMultilineUTF8_01()
{
TestNormalizeStatement(
@"var x = (int)1 switch { 1 => """"""
one
""""""U8, 2 =>
""""""
two
""""""u8 };",
@"var x = (int)1 switch
{
1 => """"""
one
""""""U8,
2 => """"""
two
""""""u8
};".NormalizeLineEndings()
);
}

[Fact]
public void TestNormalizeSwitchExpressionStringsUTF8()
{
TestNormalizeStatement(
@"var x = (int)1 switch { 1 =>
""one""u8 , 2 =>
@""two""u8 , 3 =>
""three""U8 , {} =>
@"">= 4""U8 };",
@"var x = (int)1 switch
{
1 => ""one""u8,
2 => @""two""u8,
3 => ""three""U8,
{ } => @"">= 4""U8
};".NormalizeLineEndings()
);
}

[Fact, WorkItem(52543, "https://github.com/dotnet/roslyn/issues/52543")]
public void TestNormalizeSwitchRecPattern()
{
Expand Down

0 comments on commit 428d3b3

Please sign in to comment.