Skip to content

Commit

Permalink
Move unmanaged type constraint for Span-compatible Assert.(Not)Equal …
Browse files Browse the repository at this point in the history
…to be conditional based on XUNIT_NULLABLE
  • Loading branch information
bradwilson committed Sep 26, 2022
1 parent 263da3f commit 14974b8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions EqualityAsserts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ partial class Assert
{
#if XUNIT_SPAN
/// <summary>
/// Verifies that two arrays of unmanaged type T are equal, using Span&lt;T&gt;.SequenceEqual.
/// Verifies that two arrays of un-managed type T are equal, using Span&lt;T&gt;.SequenceEqual.
/// </summary>
/// <typeparam name="T">The type of items whose arrays are to be compared</typeparam>
/// <param name="expected">The expected value</param>
Expand All @@ -33,10 +33,11 @@ partial class Assert
/// </remarks>
#if XUNIT_NULLABLE
public static void Equal<T>([AllowNull] T[] expected, [AllowNull] T[] actual)
where T : unmanaged, IEquatable<T>
#else
public static void Equal<T>(T[] expected, T[] actual)
where T : IEquatable<T>
#endif
where T : unmanaged, IEquatable<T>
{
if (expected == null && actual == null)
return;
Expand Down Expand Up @@ -243,18 +244,19 @@ public static void StrictEqual<T>(T expected, T actual) =>

#if XUNIT_SPAN
/// <summary>
/// Verifies that two arrays of unmanaged type T are not equal, using Span&lt;T&gt;.SequenceEqual.
/// Verifies that two arrays of un-managed type T are not equal, using Span&lt;T&gt;.SequenceEqual.
/// </summary>
/// <typeparam name="T">The type of items whose arrays are to be compared</typeparam>
/// <param name="expected">The expected value</param>
/// <param name="actual">The value to be compared against</param>
/// <exception cref="NotEqualException">Thrown when the arrays are equal</exception>
#if XUNIT_NULLABLE
public static void NotEqual<T>([AllowNull] T[] expected, [AllowNull] T[] actual)
where T : unmanaged, IEquatable<T>
#else
public static void NotEqual<T>(T[] expected, T[] actual)
where T : IEquatable<T>
#endif
where T : unmanaged, IEquatable<T>
{
// Call into NotEqual<object> so we get proper formatting of the sequence
if (expected == null && actual == null)
Expand Down

0 comments on commit 14974b8

Please sign in to comment.