public static IEnumerable <object[]> DistinctData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.Cast <int>().Select(x => x * DuplicateFactor))) { yield return(new object[] { results[0], ((int)results[1]) / DuplicateFactor }); } }
// For each source, run with each buffering option. /// <summary> /// Get a set of ranges, and running for each count in `counts`, with each possible ParallelMergeOption /// </summary> /// <param name="counts">The sizes of ranges to return.</param> /// <returns>Entries for test data. /// The first element is the Labeled{ParallelQuery{int}} range, /// the second element is the count, and the third is the ParallelMergeOption to use.</returns> public static IEnumerable <object[]> MergeData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.DefaultIfEmpty(Sources.OuterLoopCount), x => Options)) { yield return(results); } }
public static IEnumerable <object[]> SkipData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.DefaultIfEmpty(Sources.OuterLoopCount / 4), SkipPosition)) { yield return(results); } }
/// <summary> /// Get a set of ranges, running for each count in `counts`, with 1, 2, and 4 counts for partitions. /// </summary> /// <param name="counts">The sizes of ranges to return.</param> /// <returns>Entries for test data. /// The first element is the Labeled{ParallelQuery{int}} range, /// the second element is the count, and the third is the number of partitions or degrees of parallelism to use.</returns> public static IEnumerable <object[]> PartitioningData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.DefaultIfEmpty(Sources.OuterLoopCount), x => new[] { 1, 2, 4 })) { yield return(results); } }
public static IEnumerable <object[]> DistinctData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.Select(x => x * DuplicateFactor).DefaultIfEmpty(Sources.OuterLoopCount))) { yield return(new object[] { results[0], ((int)results[1]) / DuplicateFactor }); } }
// For each source, run with each buffering option. /// <summary> /// Get a set of ranges, and running for each count in `counts`, with each possible ParallelMergeOption /// </summary> /// <param name="counts">The sizes of ranges to return.</param> /// <returns>Entries for test data. /// The first element is the Labeled{ParallelQuery{int}} range, /// the second element is the count, and the third is the ParallelMergeOption to use.</returns> public static IEnumerable <object[]> MergeData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.Cast <int>(), x => Options)) { yield return(results); } }
/// <summary> /// Get a set of ranges, running for each count in `counts`, with 1, 2, and 4 counts for partitions. /// </summary> /// <param name="counts">The sizes of ranges to return.</param> /// <returns>Entries for test data. /// The first element is the Labeled{ParallelQuery{int}} range, /// the second element is the count, and the third is the number of partitions or degrees of parallelism to use.</returns> public static IEnumerable <object[]> PartitioningData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.Cast <int>(), x => new[] { 1, 2, 4 })) { yield return(results); } }
public static IEnumerable <object[]> JoinData(int[] counts) { // When dealing with joins, if there aren't multiple matches the ordering of the second operand is immaterial. foreach (object[] parms in Sources.Ranges(counts, i => counts)) { yield return(parms); } }
public static IEnumerable <object[]> LastData(int[] counts) { Func <int, IEnumerable <int> > positions = x => new[] { 1, x / 2 + 1, Math.Max(1, x - 1) }.Distinct(); foreach (object[] results in Sources.Ranges(counts.Cast <int>(), positions)) { yield return(results); } }
public static IEnumerable <object[]> TakeData(int[] counts) { Func <int, IEnumerable <int> > take = x => new[] { -x, -1, 0, 1, x / 2, x, x * 2 }.Distinct(); foreach (object[] results in Sources.Ranges(counts.Cast <int>(), take)) { yield return(results); } }
public static IEnumerable <object[]> GroupJoinData(int[] counts) { counts = counts.DefaultIfEmpty(Sources.OuterLoopCount / 64).ToArray(); // When dealing with joins, if there aren't multiple matches the ordering of the second operand is immaterial. foreach (object[] parms in Sources.Ranges(counts, i => counts)) { yield return(parms); } }
// // SequenceEqual // public static IEnumerable <object[]> SequenceEqualData(int[] counts) { foreach (object[] left in Sources.Ranges(counts.Cast <int>())) { foreach (object[] right in Sources.Ranges(new[] { (int)left[1] })) { yield return(new object[] { left[0], right[0], right[1] }); } } }
// // SequenceEqual // public static IEnumerable <object[]> SequenceEqualData(int[] counts) { foreach (object[] left in Sources.Ranges(counts.DefaultIfEmpty(Sources.OuterLoopCount / 4))) { foreach (object[] right in Sources.Ranges(new[] { (int)left[1] })) { yield return(new object[] { left[0], right[0], right[1] }); } } }
// Get two ranges, both from 0 to each count, and having an extra parameter denoting the degree or parallelism to use. public static IEnumerable <object[]> ZipThreadedData(int[] counts, int[] degrees) { foreach (object[] left in Sources.Ranges(counts)) { foreach (object[] right in Sources.Ranges(counts, x => degrees)) { yield return(new object[] { left[0], left[1], right[0], right[1], right[2] }); } } }
public static IEnumerable <object[]> SequenceEqualUnequalSizeData(int[] counts) { foreach (object[] left in Sources.Ranges(counts.Cast <int>())) { foreach (object[] right in Sources.Ranges(new[] { 1, ((int)left[1] - 1) / 2 + 1, (int)left[1] * 2 + 1 }.Distinct())) { yield return(new object[] { left[0], left[1], right[0], right[1] }); } } }
// // TakeWhile // public static IEnumerable <object[]> TakeWhileData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.Cast <int>())) { yield return(new[] { results[0], results[1], new[] { 0 } }); yield return(new[] { results[0], results[1], Enumerable.Range((int)results[1] / 2, ((int)results[1] - 1) / 2 + 1) }); yield return(new[] { results[0], results[1], new[] { (int)results[1] - 1 } }); } }
public static IEnumerable <object[]> SequenceEqualUnequalData(int[] counts) { foreach (object[] left in Sources.Ranges(counts.Cast <int>())) { Func <int, IEnumerable <int> > items = x => new[] { 0, x / 8, x / 2, x * 7 / 8, x - 1 }.Distinct(); foreach (object[] right in Sources.Ranges(new[] { (int)left[1] }, items)) { yield return(new object[] { left[0], right[0], right[1], right[2] }); } } }
// // SkipWhile // public static IEnumerable <object[]> SkipWhileData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.DefaultIfEmpty(Sources.OuterLoopCount / 4))) { yield return(new[] { results[0], results[1], new[] { 0 } }); yield return(new[] { results[0], results[1], Enumerable.Range((int)results[1] / 2, ((int)results[1] - 1) / 2 + 1).ToArray() }); yield return(new[] { results[0], results[1], new[] { (int)results[1] - 1 } }); } }
public static IEnumerable <object[]> ElementAtOutOfRangeData(int[] counts) { foreach (object[] results in UnorderedSources.Ranges(counts.DefaultIfEmpty(Sources.OuterLoopCount), InvalidPositions)) { yield return(results); } foreach (object[] results in Sources.Ranges(counts.DefaultIfEmpty(Sources.OuterLoopCount), InvalidPositions)) { yield return(results); } }
public static IEnumerable <object[]> SingleSpecificData(int[] counts) { Func <int, IEnumerable <int> > positions = x => new[] { 0, x / 2, Math.Max(0, x - 1) }.Distinct(); foreach (object[] results in UnorderedSources.Ranges(counts.Cast <int>(), positions)) { yield return(results); } foreach (object[] results in Sources.Ranges(counts.Cast <int>(), positions)) { yield return(results); } }
public static IEnumerable <object[]> SelectManyData(int[] counts) { foreach (object[] results in Sources.Ranges(counts.Cast <int>())) { foreach (Labeled <Func <int, int, IEnumerable <int> > > expander in Expanders()) { foreach (int count in new[] { 0, 1, 2, 8 }) { yield return(new object[] { results[0], results[1], expander, count }); } } } }
public static IEnumerable<object[]> EmptyData() { foreach (object[] query in UnorderedSources.Ranges(new[] { 0 })) { yield return new object[] { query[0], 1 }; } foreach (object[] query in Sources.Ranges(new[] { 0 })) { yield return new object[] { query[0], 1 }; } yield return new object[] { Labeled.Label("Empty-Int", ParallelEnumerable.Empty<int>()), 1 }; yield return new object[] { Labeled.Label("Empty-Decimal", ParallelEnumerable.Empty<decimal>()), 1.5M }; yield return new object[] { Labeled.Label("Empty-String", ParallelEnumerable.Empty<string>()), "default" }; }
/// <summary> /// Run through all sources, ensuring 64k elements for each core (to saturate buffers in producers/consumers). /// </summary> /// Data returned is in the format of the underlying sources. /// <returns>Rows of sourced data to check.</returns> public static IEnumerable <object[]> ProducerBlocked_Data() { // Provide enough elements to ensure all the cores get >64K ints. int elements = 64 * 1024 * Environment.ProcessorCount; foreach (object[] data in Sources.Ranges(new[] { elements })) { yield return(data); } foreach (object[] data in UnorderedSources.Ranges(new[] { elements })) { yield return(data); } }
public static IEnumerable <object[]> SingleData(int[] elements, int[] counts) { foreach (int element in elements) { foreach (object[] results in UnorderedSources.Ranges(element, counts.Cast <int>())) { yield return(new object[] { results[0], results[1], element }); } foreach (object[] results in Sources.Ranges(element, counts.Cast <int>())) { yield return(new object[] { results[0], results[1], element }); } } }
public static IEnumerable <object[]> ExceptData(int[] leftCounts) { foreach (int leftCount in leftCounts.DefaultIfEmpty(Sources.OuterLoopCount / 4)) { foreach (int rightCount in RightCounts(leftCount)) { int rightStart = 0 - rightCount / 2; foreach (object[] left in Sources.Ranges(new[] { leftCount })) { yield return(left.Concat(new object[] { UnorderedSources.Default(rightStart, rightCount), rightCount, rightStart + rightCount, Math.Max(0, leftCount - (rightCount + 1) / 2) }).ToArray()); } } } }