LibHac/tests/LibHac.Tests/SpanEqualAsserts.cs

21 lines
779 B
C#
Raw 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))
throw new EqualException(expected.ToArray(), actual.ToArray());
2021-06-24 20:45:25 +02:00
}
}