-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MemoryExtensions overloads with comparer
- Loading branch information
1 parent
1e6311a
commit 6958f74
Showing
17 changed files
with
2,658 additions
and
867 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
src/libraries/System.Memory/tests/ReadOnlySpan/Comparers.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,42 @@ | ||
// 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.Generic; | ||
using Xunit; | ||
|
||
namespace System.SpanTests | ||
{ | ||
public static partial class ReadOnlySpanTests | ||
{ | ||
private static IEnumerable<IEqualityComparer<T>?> GetDefaultEqualityComparers<T>() | ||
{ | ||
yield return null; | ||
|
||
yield return EqualityComparer<T>.Default; | ||
|
||
yield return EqualityComparer<T>.Create((i, j) => EqualityComparer<T>.Default.Equals(i, j)); | ||
|
||
if (typeof(T) == typeof(string)) | ||
{ | ||
yield return (IEqualityComparer<T>)(object)StringComparer.Ordinal; | ||
} | ||
} | ||
|
||
private static IEnumerable<IComparer<T>?> GetDefaultComparers<T>() | ||
{ | ||
yield return null; | ||
|
||
yield return Comparer<T>.Default; | ||
|
||
yield return Comparer<T>.Create((i, j) => Comparer<T>.Default.Compare(i, j)); | ||
|
||
if (typeof(T) == typeof(string)) | ||
{ | ||
yield return (IComparer<T>)(object)StringComparer.Ordinal; | ||
} | ||
} | ||
|
||
private static IEqualityComparer<T> GetFalseEqualityComparer<T>() => | ||
EqualityComparer<T>.Create((i, j) => false); | ||
} | ||
} |
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
Oops, something went wrong.