This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CoreFx #22406 Span based APIs - Text Reader Writer (#23786)
- Loading branch information
Showing
15 changed files
with
1,184 additions
and
88 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,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace System.IO.Tests | ||
{ | ||
public static class TestDataProvider | ||
{ | ||
private static readonly char[] s_charData; | ||
private static readonly char[] s_smallData; | ||
private static readonly char[] s_largeData; | ||
|
||
public static object FirstObject { get; } = (object)1; | ||
public static object SecondObject { get; } = (object)"[second object]"; | ||
public static object ThirdObject { get; } = (object)"<third object>"; | ||
public static object[] MultipleObjects { get; } = new object[] { FirstObject, SecondObject, ThirdObject }; | ||
|
||
public static string FormatStringOneObject { get; } = "Object is {0}"; | ||
public static string FormatStringTwoObjects { get; } = $"Object are '{0}', {SecondObject}"; | ||
public static string FormatStringThreeObjects { get; } = $"Objects are {0}, {SecondObject}, {ThirdObject}"; | ||
public static string FormatStringMultipleObjects { get; } = "Multiple Objects are: {0}, {1}, {2}"; | ||
|
||
static TestDataProvider() | ||
{ | ||
s_charData = new char[] | ||
{ | ||
char.MinValue, | ||
char.MaxValue, | ||
'\t', | ||
' ', | ||
'$', | ||
'@', | ||
'#', | ||
'\0', | ||
'\v', | ||
'\'', | ||
'\u3190', | ||
'\uC3A0', | ||
'A', | ||
'5', | ||
'\r', | ||
'\uFE70', | ||
'-', | ||
';', | ||
'\r', | ||
'\n', | ||
'T', | ||
'3', | ||
'\n', | ||
'K', | ||
'\u00E6' | ||
}; | ||
|
||
s_smallData = "HELLO".ToCharArray(); | ||
|
||
var data = new List<char>(); | ||
for (int count = 0; count < 1000; ++count) | ||
{ | ||
data.AddRange(s_smallData); | ||
} | ||
s_largeData = data.ToArray(); | ||
} | ||
|
||
public static char[] CharData => s_charData; | ||
|
||
public static char[] SmallData => s_smallData; | ||
|
||
public static char[] LargeData => s_largeData; | ||
} | ||
} |
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 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace System.IO.Tests | ||
{ | ||
public class CharArrayTextReader : TextReader | ||
{ | ||
private readonly char[] _charBuffer; | ||
private int _charPos = 0; | ||
|
||
public bool EndOfStream => _charPos >= _charBuffer.Length; | ||
|
||
public CharArrayTextReader(char[] data) | ||
{ | ||
_charBuffer = data; | ||
} | ||
|
||
public override int Peek() | ||
{ | ||
if (_charPos == _charBuffer.Length) | ||
{ | ||
return -1; | ||
} | ||
return _charBuffer[_charPos]; | ||
} | ||
|
||
public override int Read() | ||
{ | ||
if (_charPos == _charBuffer.Length) | ||
{ | ||
return -1; | ||
} | ||
return _charBuffer[_charPos++]; | ||
} | ||
} | ||
} |
Oops, something went wrong.