-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The most expensive thing we're doing in the binary format tests is getting the validation test method for types. I've added a cache for this, which cuts a third of the testing time for the project. Also adding some theory data helper classes for tuples for clarity and minor perf. Finally, no need to call the slow method for array index sets for multidimensional arrays.
- Loading branch information
1 parent
bb8c1c9
commit 8d62cf5
Showing
4 changed files
with
90 additions
and
61 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/Common/tests/TestUtilities/XUnit/EnumerableTupleTheoryData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections; | ||
|
||
namespace Xunit; | ||
|
||
/// <summary> | ||
/// Theory data for tuple enumeration. | ||
/// </summary> | ||
public class EnumerableTupleTheoryData<T1, T2> : IReadOnlyCollection<object[]> | ||
where T1 : notnull | ||
where T2 : notnull | ||
{ | ||
private readonly IEnumerable<(T1, T2)> _data; | ||
|
||
public int Count => _data.Count(); | ||
|
||
public EnumerableTupleTheoryData(IEnumerable<(T1, T2)> data) => _data = data; | ||
|
||
public IEnumerator<object[]> GetEnumerator() => | ||
_data.Select(i => new object[] { i.Item1, i.Item2 }).GetEnumerator(); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
} | ||
|
||
/// <inheritdoc cref="EnumerableTupleTheoryData{T1, T2}"/> | ||
public class EnumerableTupleTheoryData<T1, T2, T3> : IReadOnlyCollection<object[]> | ||
where T1 : notnull | ||
where T2 : notnull | ||
where T3 : notnull | ||
{ | ||
private readonly IEnumerable<(T1, T2, T3)> _data; | ||
|
||
public int Count => _data.Count(); | ||
|
||
public EnumerableTupleTheoryData(IEnumerable<(T1, T2, T3)> data) => _data = data; | ||
|
||
public IEnumerator<object[]> GetEnumerator() => | ||
_data.Select(i => new object[] { i.Item1, i.Item2, i.Item3 }).GetEnumerator(); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters