public void FastParallelMapToArrayErrors() { var a = new int[1]; var b = new int[2]; Assert.Throws <ArgumentNullException>(() => FastParallel.MapToArray <int, int>(null, a, null, i => i)); Assert.Throws <ArgumentNullException>(() => FastParallel.MapToArray(a, null, null, i => i)); Assert.Throws <ArgumentNullException>(() => FastParallel.MapToArray(a, a, null, null)); Assert.Throws <ArgumentException>(() => FastParallel.MapToArray(a, a, 0, i => i)); Assert.Throws <ArgumentException>(() => FastParallel.MapToArray(a, b, 0, i => i)); }
public void FastParallelMapToArray(int?maxThreads, int count) { var inArray = new int[count]; foreach (var index in Enumerable.Range(0, count)) { inArray[index] = index; } var outArray = new int[count]; FastParallel.MapToArray(inArray, outArray, maxThreads, value => value + 1); foreach (var index in Enumerable.Range(0, count)) { Assert.AreEqual(index, inArray[index]); Assert.AreEqual(inArray[index] + 1, outArray[index]); } }