forked from stryker-mutator/stryker-net
-
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.
Add support for Utf8 string literals
- Loading branch information
1 parent
4f5fefc
commit 705bc66
Showing
6 changed files
with
158 additions
and
5 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 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
50 changes: 50 additions & 0 deletions
50
integrationtest/TargetProjects/NetCoreTestProject.XUnit/String/Utf8StringMagicTests.cs
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,50 @@ | ||
using ExampleProject.String; | ||
using Xunit; | ||
|
||
namespace ExampleProject.XUnit.String | ||
{ | ||
public class Utf8StringMagicTests | ||
{ | ||
[Fact] | ||
public void AddTwoStrings() | ||
{ | ||
var sut = new Utf8StringMagic(); | ||
var actual = sut.HelloWorld(); | ||
Assert.Equal("Hello World!"u8, actual); | ||
} | ||
|
||
[Fact] | ||
public void IsNullOrEmpty() | ||
{ | ||
var sut = new Utf8StringMagic(); | ||
var actual = sut.IsNullOrEmpty("hello"u8); | ||
Assert.False(actual); | ||
} | ||
|
||
[Fact] | ||
public void IsNullOrEmpty_Empty() | ||
{ | ||
var sut = new Utf8StringMagic(); | ||
var actual = sut.IsNullOrEmpty(""u8); | ||
Assert.True(actual); | ||
} | ||
|
||
[Fact] | ||
public void Referenced() | ||
{ | ||
var sut = new Utf8StringMagic(); | ||
var input = "hello"u8; | ||
sut.Referenced(out input); | ||
Assert.Equal("world"u8, input); | ||
} | ||
|
||
[Fact] | ||
public void ReferencedEmpty() | ||
{ | ||
var sut = new Utf8StringMagic(); | ||
var input = "hello"u8; | ||
sut.ReferencedEmpty(out input); | ||
Assert.Equal(""u8, input); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
integrationtest/TargetProjects/TargetProject/String/Utf8StringMagic.cs
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,33 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace ExampleProject.String | ||
{ | ||
public class Utf8StringMagic | ||
{ | ||
public ReadOnlySpan<byte> HelloWorld() | ||
{ | ||
var a = ""; | ||
return "Hello"u8 + " "u8 + "World!"u8; | ||
} | ||
|
||
public void Referenced(out ReadOnlySpan<byte> test) | ||
{ | ||
test = "world"u8; | ||
} | ||
|
||
public void ReferencedEmpty(out ReadOnlySpan<byte> test) | ||
{ | ||
test = ""u8; | ||
} | ||
|
||
public bool IsNullOrEmpty(ReadOnlySpan<byte> myString) | ||
{ | ||
if (myString.IsEmpty) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
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 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