public void GlobalSetup() { array = ValueEnumerable.Range(0, Count).ToArray(); intervalArray = ValueEnumerable.Range(0, Count + 200).ToArray(); list = ValueEnumerable.Range(0, Count).ToList(); intervalList = ValueEnumerable.Range(0, Count + 200).ToList(); }
public void GlobalSetup() { enumerable = TestEnumerable.ReferenceType(10); #pragma warning disable HLQ001 // Assigment to interface causes boxing of enumerator list = ValueEnumerable.Range(0, 10).ToList(); #pragma warning restore HLQ001 // Assigment to interface causes boxing of enumerator }
public void GlobalSetup() { array = ValueEnumerable.Range(0, Count).ToArray(); intervalArray = ValueEnumerable.Range(0, Count + 200).ToArray(); #pragma warning disable HLQ001 // Assigment to interface causes boxing of enumerator list = ValueEnumerable.Range(0, Count).ToList(); intervalList = ValueEnumerable.Range(0, Count + 200).ToList(); #pragma warning restore HLQ001 // Assigment to interface causes boxing of enumerator }
public int Hyperlinq_Range_ForEach() { var sum = 0; foreach (var item in ValueEnumerable.Range(0, Count)) { sum += item; } return(sum); }
public void Indexer_With_IndexOutOfRange_Must_Throw(int count, int index) { // Arrange // Act Func <int> action = () => ValueEnumerable.Range(0, count)[index]; // Assert _ = action.Must().Throw <IndexOutOfRangeException>(); }
public int Hyperlinq_Range_For() { var enumerable = ValueEnumerable.Range(0, Count); var sum = 0; for (var index = 0; index < enumerable.Count; index++) { sum += enumerable[index]; } return(sum); }
public int Hyperlinq() { var items = ValueEnumerable.Range(Start, Count); var sum = 0; foreach (var item in items) { sum += item; } return(sum); }
public void Range_SelectVector_Sum_Must_Succeed(int start, int count) { // Arrange var expected = Enumerable.Range(start, count).Select(item => item * 2).Sum(); // Act var result = ValueEnumerable.Range(start, count).SelectVector(item => item * 2, item => item * 2).Sum(); // Assert _ = result.Must() .BeEqualTo(expected); }
public void Range_Any_With_ValidData_Must_Succeed(int start, int count) { // Arrange var expected = Enumerable.Any(Enumerable.Range(start, count)); // Act var result = ValueEnumerable.Range(start, count).Any(); // Assert _ = result.Must() .BeEqualTo(expected); }
public void Range_Contains_With_ValidData_Must_Succeed(int start, int count, int value) { // Arrange var expected = Enumerable.Range(start, count).Contains(value); // Act var result = ValueEnumerable.Range(start, count).Contains(value); // Assert _ = result.Must() .BeEqualTo(expected); }
public void Range_With_NegativeCount_Must_Throw(int count) { // Arrange // Act Action action = () => _ = ValueEnumerable.Range(0, count); // Assert _ = action.Must() .Throw <ArgumentOutOfRangeException>() .EvaluateTrue(exception => exception.ParamName == "count"); }
public void Range_Take_With_ValidData_Must_Succeed(int start, int count, int take) { // Arrange var expected = Enumerable.Range(start, count).Take(take); // Act var result = ValueEnumerable.Range(start, count).Take(take); // Assert _ = result.Must() .BeEnumerableOf <int>() .BeEqualTo(expected); }
public void Range_Skip_With_ValidData_Must_Succeed(int start, int count, int skip) { // Arrange var expected = Enumerable.Skip(Enumerable.Range(start, count), skip); // Act var result = ValueEnumerable.Range(start, count).Skip(skip); // Assert _ = result.Must() .BeEnumerableOf <int>() .BeEqualTo(expected); }
public int Hyperlinq_ValueDelegate() { var items = ValueEnumerable .Range(Start, Count) .Select <int, TripleOfInt32>(); var sum = 0; foreach (var item in items) { sum += item; } return(sum); }
public void Range_SelectVector_ToList_Must_Succeed(int start, int count) { // Arrange var expected = Enumerable.ToList(Enumerable.Select(Enumerable.Range(start, count), item => item * 2)); // Act var result = ValueEnumerable.Range(start, count).SelectVector(item => item * 2, item => item * 2).ToList(); // Assert _ = result.Must() .BeOfType <List <int> >() .BeEnumerableOf <int>() .BeEqualTo(expected); }
public void Range_ToArray_With_ValidData_Must_Succeed(int start, int count) { // Arrange var expected = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Range(start, count)); // Act var result = ValueEnumerable.Range(start, count).ToArray(); // Assert _ = result.Must() .BeArrayOf <int>() .BeEnumerableOf <int>() .BeEqualTo(expected); }
public void Range_With_ToList_Must_Succeed(int start, int count) { // Arrange var expected = Enumerable.Range(start, count).ToList(); // Act var result = ValueEnumerable.Range(start, count).ToList(); // Assert _ = result.Must() .BeOfType <List <int> >() .BeEnumerableOf <int>() .BeEqualTo(expected); }
public void Distinct_With_LargeData_Must_Succeed(int count) { // Arrange var source = ValueEnumerable.Range(0, count).ToArray(); var expected = Enumerable .Distinct(source); // Act var result = source.AsValueEnumerable() .Distinct(); // Assert _ = result.Must() .BeEnumerableOf <int>() .BeEqualTo(expected, testRefStructs: false, testRefReturns: false); _ = result.SequenceEqual(expected).Must().BeTrue(); }
public void GlobalSetup() { linqRange = System.Linq.Enumerable.Range(0, Count); hyperlinqRange = ValueEnumerable.Range(0, Count); array = hyperlinqRange.ToArray(); memory = array.AsMemory(); list = new List <int>(hyperlinqRange); linkedList = new LinkedList <int>(hyperlinqRange); enumerableReference = TestEnumerable.ReferenceType(Count); enumerableValue = TestEnumerable.ValueType(Count); collectionReference = TestCollection.ReferenceType(Count); collectionValue = TestCollection.ValueType(Count); listReference = TestList.ReferenceType(Count); listValue = TestList.ValueType(Count); asyncEnumerableReference = TestAsyncEnumerable.ReferenceType(Count); asyncEnumerableValue = TestAsyncEnumerable.ValueType(Count); }
public int Hyperlinq_Pool() { using var array = ValueEnumerable.Range(Start, Count).Select(item => item * 2).ToArray(MemoryPool <int> .Shared); return(Count == 0 ? default : array.Memory.Span[0]); }
public int[] Hyperlinq() => ValueEnumerable .Range(Start, Count) .Select(item => item * 3) .ToArray();
public int[] Hyperlinq() => ValueEnumerable.Range(0, Count).Where(item => (item & 0x01) == 0).Select(item => item * 2).ToArray();
public void GlobalSetup() => list = ValueEnumerable.Range(0, Count).ToList();
public int[] Hyperlinq() => ValueEnumerable .Range(Start, Count) .ToArray();
public void GlobalSetup() { var range = ValueEnumerable.Range(0, Count); array = ImmutableArray.CreateRange(range); }
public void GlobalSetup() => array = ValueEnumerable.Range(0, Count).ToArray();
public List <int> Hyperlinq() => ValueEnumerable.Range(0, Count).Select(item => item % 10).Distinct().ToList();
public int[] Hyperlinq_SIMD() => ValueEnumerable .Range(Start, Count) .SelectVector(item => item * 3, item => item * 3) .ToArray();
public int[] Hyperlinq_ValueDelegate_SIMD() => ValueEnumerable .Range(Start, Count) .SelectVector <int, TripleOfInt32>() .ToArray();
protected static int[] GetSequentialValues(int count) => ValueEnumerable.Range(0, count).ToArray();