-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
7d0a348
commit 9d2d6da
Showing
6 changed files
with
130 additions
and
71 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
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
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,37 @@ | ||
using BenchmarkDotNet.Attributes; | ||
using BenchmarkDotNet.Configs; | ||
using System; | ||
|
||
namespace Parlot.Benchmarks | ||
{ | ||
[MemoryDiagnoser, GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory), ShortRunJob] | ||
public class ParlotBenchmarks | ||
{ | ||
private const string _stringWithEscapes = "This is a new line \\n \\t and a tab and some \\xa0"; | ||
private const string _stringWithoutEscapes = "This is a new line \n \t and a tab and some \xa0"; | ||
|
||
[Benchmark] | ||
public TextSpan DecodeStringWithEscapes() | ||
{ | ||
return Character.DecodeString(_stringWithEscapes); | ||
} | ||
|
||
[Benchmark] | ||
public TextSpan DecodeStringWithoutEscapes() | ||
{ | ||
return Character.DecodeString(_stringWithoutEscapes); | ||
} | ||
|
||
[Benchmark] | ||
public string DecodeStringWithEscapesToString() | ||
{ | ||
return Character.DecodeString(_stringWithEscapes).ToString(); | ||
} | ||
|
||
[Benchmark] | ||
public string DecodeStringWithoutEscapesToString() | ||
{ | ||
return Character.DecodeString(_stringWithoutEscapes).ToString(); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,15 +1,17 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit; | ||
|
||
namespace Parlot.Tests | ||
{ | ||
public class CharacterTests | ||
{ | ||
[Theory] | ||
[InlineData("a\\bc", "a\bc")] | ||
[InlineData("\\xa0", "\xa0")] | ||
[InlineData("\\xfh", "\xfh")] | ||
[InlineData("\\u1234", "\u1234")] | ||
public void ShouldDescodeString(string text, string expected) | ||
{ | ||
Assert.Equal(expected, Character.DecodeString(text.AsSpan()).ToString()); | ||
Assert.Equal(expected, Character.DecodeString(new TextSpan(text)).ToString()); | ||
} | ||
} | ||
} |