LibHac/tests/LibHac.Tests/SpanEqualAsserts.cs

21 lines
795 B
C#
Raw Permalink Normal View History

2021-06-24 20:45:25 +02:00
using System;
using Xunit.Sdk;
// ReSharper disable once CheckNamespace
2021-11-14 20:08:57 +01:00
namespace Xunit;
public partial class Assert
2021-06-24 20:45:25 +02:00
{
2021-11-14 20:08:57 +01:00
/// <summary>
/// Verifies that two spans are equal, using a default comparer.
/// </summary>
/// <typeparam name="T">The type of the objects to be compared</typeparam>
/// <param name="expected">The expected value</param>
/// <param name="actual">The value to be compared against</param>
/// <exception cref="EqualException">Thrown when the objects are not equal</exception>
public static void Equal<T>(ReadOnlySpan<T> expected, ReadOnlySpan<T> actual) where T : unmanaged, IEquatable<T>
2021-06-24 20:45:25 +02:00
{
2021-11-14 20:08:57 +01:00
if (!expected.SequenceEqual(actual))
2023-10-09 06:03:56 +02:00
throw EqualException.ForMismatchedValues(expected.ToArray(), actual.ToArray());
2021-06-24 20:45:25 +02:00
}
}