-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
ReverseTests.cs
96 lines (86 loc) · 3.02 KB
/
ReverseTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Xunit;
namespace System.Linq.Parallel.Tests
{
public static class ReverseTests
{
[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(2)]
[InlineData(16)]
public static void Reverse_Unordered(int count)
{
IntegerRangeSet seen = new IntegerRangeSet(0, count);
foreach (int i in UnorderedSources.Default(count).Reverse())
{
seen.Add(i);
}
seen.AssertComplete();
}
[Fact]
[OuterLoop]
public static void Reverse_Unordered_Longrunning()
{
Reverse_Unordered(Sources.OuterLoopCount);
}
[Theory]
[MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, 16 }, MemberType = typeof(Sources))]
public static void Reverse(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
int seen = count;
foreach (int i in query.Reverse())
{
Assert.Equal(--seen, i);
}
Assert.Equal(0, seen);
}
[Theory]
[OuterLoop]
[MemberData(nameof(Sources.OuterLoopRanges), MemberType = typeof(Sources))]
public static void Reverse_Longrunning(Labeled<ParallelQuery<int>> labeled, int count)
{
Reverse(labeled, count);
}
[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(2)]
[InlineData(16)]
public static void Reverse_Unordered_NotPipelined(int count)
{
IntegerRangeSet seen = new IntegerRangeSet(0, count);
Assert.All(UnorderedSources.Default(count).Reverse().ToList(), x => seen.Add(x));
seen.AssertComplete();
}
[Fact]
[OuterLoop]
public static void Reverse_Unordered_NotPipelined_Longrunning()
{
Reverse_Unordered_NotPipelined(Sources.OuterLoopCount);
}
[Theory]
[MemberData(nameof(Sources.Ranges), new[] { 0, 1, 2, 16 }, MemberType = typeof(Sources))]
public static void Reverse_NotPipelined(Labeled<ParallelQuery<int>> labeled, int count)
{
ParallelQuery<int> query = labeled.Item;
int seen = count;
Assert.All(query.Reverse().ToList(), x => Assert.Equal(--seen, x));
Assert.Equal(0, seen);
}
[Theory]
[OuterLoop]
[MemberData(nameof(Sources.OuterLoopRanges), MemberType = typeof(Sources))]
public static void Reverse_NotPipelined_Longrunning(Labeled<ParallelQuery<int>> labeled, int count)
{
Reverse_NotPipelined(labeled, count);
}
[Fact]
public static void Reverse_ArgumentNullException()
{
AssertExtensions.Throws<ArgumentNullException>("source", () => ((ParallelQuery<object>)null).Reverse());
}
}
}