|
1 | | -using static SpanExtensions.Tests.UnitTests.TestHelper; |
| 1 | +using Newtonsoft.Json.Linq; |
| 2 | +using static SpanExtensions.Tests.UnitTests.TestHelper; |
2 | 3 |
|
3 | 4 | namespace SpanExtensions.Tests.UnitTests |
4 | 5 | { |
5 | 6 | public static partial class SpanSplitTests |
6 | 7 | { |
7 | 8 | public sealed class SplitAnyString |
8 | 9 | { |
9 | | - [Fact] |
10 | | - public void EnumerationReturnsSpans() |
11 | | - { |
12 | | -#pragma warning disable CS0183 // 'is' expression's given expression is always of the provided type |
13 | | - foreach(var span in "abaca".ToCharArray().AsSpan().SplitAny(['b', 'c'], StringSplitOptions.None)) |
14 | | - { |
15 | | - Assert.True(span is Span<char>); |
16 | | - } |
| 10 | +// [Fact] |
| 11 | +// public void EnumerationReturnsSpans() |
| 12 | +// { |
| 13 | +//#pragma warning disable CS0183 // 'is' expression's given expression is always of the provided type |
| 14 | +// foreach(ReadOnlySpan<char> span in "abaca".ToCharArray().AsSpan().SplitAny(['b', 'c'], StringSplitOptions.None)) |
| 15 | +// { |
| 16 | +// Assert.True(span is Span<char>); |
| 17 | +// } |
17 | 18 |
|
18 | | - foreach(var span in "abaca".ToCharArray().AsSpan().SplitAny(['b', 'c'], 10, StringSplitOptions.None)) |
19 | | - { |
20 | | - Assert.True(span is Span<char>); |
21 | | - } |
22 | | -#pragma warning restore CS0183 // 'is' expression's given expression is always of the provided type |
23 | | - } |
| 19 | +// foreach(ReadOnlySpan<char> span in "abaca".ToCharArray().AsSpan().SplitAny(['b', 'c'], 10, StringSplitOptions.None)) |
| 20 | +// { |
| 21 | +// Assert.True(span is Span<char>); |
| 22 | +// } |
| 23 | +//#pragma warning restore CS0183 // 'is' expression's given expression is always of the provided type |
| 24 | +// } |
24 | 25 |
|
25 | 26 | [Fact] |
26 | 27 | public void EmptySourceResultInEmptySpan() |
@@ -421,21 +422,20 @@ public void EmptyDelimiterSpanResultsSameAsCountEqualOne() |
421 | 422 | public void NegativeCountThrowsArgumentOutOfRangeException() |
422 | 423 | { |
423 | 424 | Assert.Throws<ArgumentOutOfRangeException>(() => "aabc".ToCharArray().AsSpan().SplitAny(['b', 'c'], -1, StringSplitOptions.None)); |
424 | | - Assert.Throws<ArgumentOutOfRangeException>(() => "aabc".ToCharArray().AsSpan().SplitAny(['d', 'e'], -1, StringSplitOptions.None)); |
425 | 425 | } |
426 | 426 |
|
427 | | - [Fact] |
428 | | - public void UndefinedCountExceedingBehaviourOptionThrowsArgumentException() |
| 427 | + [Theory] |
| 428 | + [InlineData(new char[] { 'b', 'c' }, 1, StringSplitOptions.None, byte.MaxValue)] |
| 429 | + public void UndefinedCountExceedingBehaviourOptionThrowsArgumentException(char[] delimiters, int count, StringSplitOptions options, int value) |
429 | 430 | { |
430 | | - Assert.Throws<ArgumentException>(() => "aabc".ToCharArray().AsSpan().SplitAny(['b', 'c'], 1, StringSplitOptions.None, (CountExceedingBehaviour)255)); |
431 | | - Assert.Throws<ArgumentException>(() => "aabc".ToCharArray().AsSpan().SplitAny(['d', 'e'], 1, StringSplitOptions.None, (CountExceedingBehaviour)255)); |
| 431 | + Assert.Throws<ArgumentException>(() => "aabc".ToCharArray().AsSpan().SplitAny(delimiters, count, options, (CountExceedingBehaviour) value)); |
432 | 432 | } |
433 | 433 |
|
434 | | - [Fact] |
435 | | - public void UndefinedStringSplitOptionsThrowsArgumentException() |
| 434 | + [Theory] |
| 435 | + [InlineData(new char[] { 'b', 'c' }, byte.MaxValue)] |
| 436 | + public void UndefinedStringSplitOptionsThrowsArgumentException(char[] delimiters, int value) |
436 | 437 | { |
437 | | - Assert.Throws<ArgumentException>(() => "aabc".ToCharArray().AsSpan().SplitAny(['b', 'c'], (StringSplitOptions)255)); |
438 | | - Assert.Throws<ArgumentException>(() => "aabc".ToCharArray().AsSpan().SplitAny(['d', 'e'], (StringSplitOptions)255)); |
| 438 | + Assert.Throws<ArgumentException>(() => "aabc".ToCharArray().AsSpan().SplitAny(delimiters, (StringSplitOptions)value)); |
439 | 439 | } |
440 | 440 | } |
441 | 441 | } |
|
0 commit comments