Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Runtime/tests/System/TimeSpanTests.netcoreapp.cs')
-rw-r--r--src/System.Runtime/tests/System/TimeSpanTests.netcoreapp.cs24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/System.Runtime/tests/System/TimeSpanTests.netcoreapp.cs b/src/System.Runtime/tests/System/TimeSpanTests.netcoreapp.cs
index 18a46a8752..1478e6855f 100644
--- a/src/System.Runtime/tests/System/TimeSpanTests.netcoreapp.cs
+++ b/src/System.Runtime/tests/System/TimeSpanTests.netcoreapp.cs
@@ -111,11 +111,27 @@ namespace System.Tests
AssertExtensions.Throws<ArgumentException>("divisor", () => TimeSpan.FromDays(1).Divide(double.NaN));
}
+ public static IEnumerable<object[]> Parse_ValidWithOffsetCount_TestData()
+ {
+ foreach (object[] inputs in Parse_Valid_TestData())
+ {
+ yield return new object[] { inputs[0], 0, ((string)inputs[0]).Length, inputs[1], inputs[2] };
+ }
+
+ yield return new object[] { " 12:24:02 ", 5, 8, null, new TimeSpan(0, 12, 24, 2, 0) };
+ yield return new object[] { " 12:24:02 ", 6, 7, null, new TimeSpan(0, 2, 24, 2, 0) };
+ yield return new object[] { " 12:24:02 ", 6, 6, null, new TimeSpan(0, 2, 24, 0, 0) };
+ yield return new object[] { "12:24:02.01", 0, 8, CultureInfo.InvariantCulture, new TimeSpan(0, 12, 24, 2, 0) };
+ yield return new object[] { "1:1:1.00000001", 0, 7, CultureInfo.InvariantCulture, new TimeSpan(1, 1, 1) };
+ yield return new object[] { "1:1:.00000001", 0, 6, CultureInfo.InvariantCulture, new TimeSpan(36600000000) };
+ yield return new object[] { "24:00:00", 1, 7, null, new TimeSpan(4, 0, 0) };
+ }
+
[Theory]
- [MemberData(nameof(Parse_Valid_TestData))]
- public static void Parse_Span(string inputString, IFormatProvider provider, TimeSpan expected)
+ [MemberData(nameof(Parse_ValidWithOffsetCount_TestData))]
+ public static void Parse_Span(string inputString, int offset, int count, IFormatProvider provider, TimeSpan expected)
{
- ReadOnlySpan<char> input = inputString.AsSpan();
+ ReadOnlySpan<char> input = inputString.AsSpan(offset, count);
TimeSpan result;
Assert.Equal(expected, TimeSpan.Parse(input, provider));
@@ -125,7 +141,7 @@ namespace System.Tests
// Also negate
if (!char.IsWhiteSpace(input[0]))
{
- input = ("-" + inputString).AsSpan();
+ input = ("-" + inputString.Substring(offset, count)).AsSpan();
expected = -expected;
Assert.Equal(expected, TimeSpan.Parse(input, provider));