Method Equal
- Namespace
- Xunit
- Assembly
- xunit.v3.assert.dll
Equal<T>(IEnumerable<T>?, IEnumerable<T>?)
Verifies that two sequences are equivalent, using a default comparer.
public static void Equal<T>(IEnumerable<T>? expected, IEnumerable<T>? actual)
Parameters
expectedIEnumerable<T>The expected value
actualIEnumerable<T>The value to be compared against
Type Parameters
TThe type of the objects to be compared
Exceptions
Thrown when the objects are not equal
Equal<T>(IEnumerable<T>?, IEnumerable<T>?, IEqualityComparer<T>)
Verifies that two sequences are equivalent, using a custom equatable comparer.
public static void Equal<T>(IEnumerable<T>? expected, IEnumerable<T>? actual, IEqualityComparer<T> comparer)
Parameters
expectedIEnumerable<T>The expected value
actualIEnumerable<T>The value to be compared against
comparerIEqualityComparer<T>The comparer used to compare the two objects
Type Parameters
TThe type of the objects to be compared
Exceptions
Thrown when the objects are not equal
Equal<T>(IEnumerable<T>?, IEnumerable<T>?, Func<T, T, bool>)
Verifies that two collections are equal, using a comparer function against items in the two collections.
public static void Equal<T>(IEnumerable<T>? expected, IEnumerable<T>? actual, Func<T, T, bool> comparer)
Parameters
expectedIEnumerable<T>The expected value
actualIEnumerable<T>The value to be compared against
comparerFunc<T, T, bool>The function to compare two items for equality
Type Parameters
TThe type of the objects to be compared
Equal<T>(T[], T[])
Verifies that two arrays of un-managed type T are equal, using Span<T>.SequenceEqual. This can be significantly faster than generic enumerables, when the collections are actually equal, because the system can optimize packed-memory comparisons for value type arrays.
public static void Equal<T>(T[] expected, T[] actual) where T : unmanaged, IEquatable<T>
Parameters
expectedT[]The expected value
actualT[]The value to be compared against
Type Parameters
TThe type of items whose arrays are to be compared
Remarks
If SequenceEqual<T>(Span<T>, ReadOnlySpan<T>) fails, a call to Equal<T>(T, T) is made, to provide a more meaningful error message.
Equal<T>(T, T)
Verifies that two objects are equal, using a default comparer.
public static void Equal<T>(T expected, T actual)
Parameters
expectedTThe expected value
actualTThe value to be compared against
Type Parameters
TThe type of the objects to be compared
Equal<T>(T, T, Func<T, T, bool>)
Verifies that two objects are equal, using a custom comparer function.
public static void Equal<T>(T expected, T actual, Func<T, T, bool> comparer)
Parameters
expectedTThe expected value
actualTThe value to be compared against
comparerFunc<T, T, bool>The comparer used to compare the two objects
Type Parameters
TThe type of the objects to be compared
Equal<T>(T, T, IEqualityComparer<T>)
Verifies that two objects are equal, using a custom equatable comparer.
public static void Equal<T>(T expected, T actual, IEqualityComparer<T> comparer)
Parameters
expectedTThe expected value
actualTThe value to be compared against
comparerIEqualityComparer<T>The comparer used to compare the two objects
Type Parameters
TThe type of the objects to be compared
Equal(double, double, int)
Verifies that two double values are equal, within the number of decimal
places given by precision. The values are rounded before comparison.
public static void Equal(double expected, double actual, int precision)
Parameters
expecteddoubleThe expected value
actualdoubleThe value to be compared against
precisionintThe number of decimal places (valid values: 0-15)
Equal(double, double, int, MidpointRounding)
Verifies that two double values are equal, within the number of decimal
places given by precision. The values are rounded before comparison.
The rounding method to use is given by rounding
public static void Equal(double expected, double actual, int precision, MidpointRounding rounding)
Parameters
expecteddoubleThe expected value
actualdoubleThe value to be compared against
precisionintThe number of decimal places (valid values: 0-15)
roundingMidpointRoundingRounding method to use to process a number that is midway between two numbers
Equal(double, double, double)
Verifies that two double values are equal, within the tolerance given by
tolerance (positive or negative).
public static void Equal(double expected, double actual, double tolerance)
Parameters
expecteddoubleThe expected value
actualdoubleThe value to be compared against
tolerancedoubleThe allowed difference between values
Equal(float, float, int)
Verifies that two float values are equal, within the number of decimal
places given by precision. The values are rounded before comparison.
public static void Equal(float expected, float actual, int precision)
Parameters
expectedfloatThe expected value
actualfloatThe value to be compared against
precisionintThe number of decimal places (valid values: 0-15)
Equal(float, float, int, MidpointRounding)
Verifies that two float values are equal, within the number of decimal
places given by precision. The values are rounded before comparison.
The rounding method to use is given by rounding
public static void Equal(float expected, float actual, int precision, MidpointRounding rounding)
Parameters
expectedfloatThe expected value
actualfloatThe value to be compared against
precisionintThe number of decimal places (valid values: 0-15)
roundingMidpointRoundingRounding method to use to process a number that is midway between two numbers
Equal(float, float, float)
Verifies that two float values are equal, within the tolerance given by
tolerance (positive or negative).
public static void Equal(float expected, float actual, float tolerance)
Parameters
expectedfloatThe expected value
actualfloatThe value to be compared against
tolerancefloatThe allowed difference between values
Equal(decimal, decimal, int)
Verifies that two decimal values are equal, within the number of decimal
places given by precision. The values are rounded before comparison.
public static void Equal(decimal expected, decimal actual, int precision)
Parameters
expecteddecimalThe expected value
actualdecimalThe value to be compared against
precisionintThe number of decimal places (valid values: 0-28)
Equal(DateTime, DateTime)
Verifies that two DateTime values are equal.
public static void Equal(DateTime expected, DateTime actual)
Parameters
Equal(DateTime, DateTime, TimeSpan)
Verifies that two DateTime values are equal, within the precision
given by precision.
public static void Equal(DateTime expected, DateTime actual, TimeSpan precision)
Parameters
expectedDateTimeThe expected value
actualDateTimeThe value to be compared against
precisionTimeSpanThe allowed difference in time where the two dates are considered equal
Equal(DateTimeOffset, DateTimeOffset)
Verifies that two DateTimeOffset values are equal.
public static void Equal(DateTimeOffset expected, DateTimeOffset actual)
Parameters
expectedDateTimeOffsetThe expected value
actualDateTimeOffsetThe value to be compared against
Equal(DateTimeOffset, DateTimeOffset, TimeSpan)
Verifies that two DateTimeOffset values are equal, within the precision
given by precision.
public static void Equal(DateTimeOffset expected, DateTimeOffset actual, TimeSpan precision)
Parameters
expectedDateTimeOffsetThe expected value
actualDateTimeOffsetThe value to be compared against
precisionTimeSpanThe allowed difference in time where the two dates are considered equal
Equal<T>(Memory<T>, Memory<T>)
Verifies that two Memory values are equivalent.
public static void Equal<T>(Memory<T> expectedMemory, Memory<T> actualMemory) where T : IEquatable<T>
Parameters
Type Parameters
T
Exceptions
Thrown when the Memory values are not equivalent.
Equal<T>(Memory<T>, ReadOnlyMemory<T>)
Verifies that two Memory values are equivalent.
public static void Equal<T>(Memory<T> expectedMemory, ReadOnlyMemory<T> actualMemory) where T : IEquatable<T>
Parameters
expectedMemoryMemory<T>The expected Memory value.
actualMemoryReadOnlyMemory<T>The actual Memory value.
Type Parameters
T
Exceptions
Thrown when the Memory values are not equivalent.
Equal<T>(ReadOnlyMemory<T>, Memory<T>)
Verifies that two Memory values are equivalent.
public static void Equal<T>(ReadOnlyMemory<T> expectedMemory, Memory<T> actualMemory) where T : IEquatable<T>
Parameters
expectedMemoryReadOnlyMemory<T>The expected Memory value.
actualMemoryMemory<T>The actual Memory value.
Type Parameters
T
Exceptions
Thrown when the Memory values are not equivalent.
Equal<T>(ReadOnlyMemory<T>, ReadOnlyMemory<T>)
Verifies that two Memory values are equivalent.
public static void Equal<T>(ReadOnlyMemory<T> expectedMemory, ReadOnlyMemory<T> actualMemory) where T : IEquatable<T>
Parameters
expectedMemoryReadOnlyMemory<T>The expected Memory value.
actualMemoryReadOnlyMemory<T>The actual Memory value.
Type Parameters
T
Exceptions
Thrown when the Memory values are not equivalent.
Equal<T>(ReadOnlySpan<T>, T[])
Verifies that a span and an array contain the same values in the same order.
public static void Equal<T>(ReadOnlySpan<T> expectedSpan, T[] actualArray) where T : IEquatable<T>
Parameters
expectedSpanReadOnlySpan<T>The expected span value.
actualArrayT[]The actual array value.
Type Parameters
T
Exceptions
Thrown when the collections are not equal.
Equal<T>(Span<T>, Span<T>)
Verifies that two spans contain the same values in the same order.
public static void Equal<T>(Span<T> expectedSpan, Span<T> actualSpan) where T : IEquatable<T>
Parameters
Type Parameters
T
Exceptions
Thrown when the spans are not equal.
Equal<T>(Span<T>, ReadOnlySpan<T>)
Verifies that two spans contain the same values in the same order.
public static void Equal<T>(Span<T> expectedSpan, ReadOnlySpan<T> actualSpan) where T : IEquatable<T>
Parameters
expectedSpanSpan<T>The expected span value.
actualSpanReadOnlySpan<T>The actual span value.
Type Parameters
T
Exceptions
Thrown when the spans are not equal.
Equal<T>(ReadOnlySpan<T>, Span<T>)
Verifies that two spans contain the same values in the same order.
public static void Equal<T>(ReadOnlySpan<T> expectedSpan, Span<T> actualSpan) where T : IEquatable<T>
Parameters
expectedSpanReadOnlySpan<T>The expected span value.
actualSpanSpan<T>The actual span value.
Type Parameters
T
Exceptions
Thrown when the spans are not equal.
Equal<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
Verifies that two spans contain the same values in the same order.
public static void Equal<T>(ReadOnlySpan<T> expectedSpan, ReadOnlySpan<T> actualSpan) where T : IEquatable<T>
Parameters
expectedSpanReadOnlySpan<T>The expected span value.
actualSpanReadOnlySpan<T>The actual span value.
Type Parameters
T
Exceptions
Thrown when the spans are not equal.
Equal(string?, string?)
Verifies that two strings are equivalent.
public static void Equal(string? expected, string? actual)
Parameters
Exceptions
Thrown when the strings are not equivalent.
Equal(ReadOnlySpan<char>, ReadOnlySpan<char>, bool, bool, bool, bool)
Verifies that two strings are equivalent.
public static void Equal(ReadOnlySpan<char> expected, ReadOnlySpan<char> actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)
Parameters
expectedReadOnlySpan<char>The expected string value.
actualReadOnlySpan<char>The actual string value.
ignoreCaseboolIf set to
true, ignores cases differences. The invariant culture is used.ignoreLineEndingDifferencesboolIf set to
true, treats \r\n, \r, and \n as equivalent.ignoreWhiteSpaceDifferencesboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.ignoreAllWhiteSpaceboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks), including zero quantities, as equivalent.
Remarks
The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider
the following characters to be white-space:
Tab (\t),
Space (\u0020),
No-Break Space (\u00A0),
Ogham Space Mark (\u1680),
Mongolian Vowel Separator (\u180E),
En Quad (\u2000),
Em Quad (\u2001),
En Space (\u2002),
Em Space (\u2003),
Three-Per-Em Space (\u2004),
Four-Per-Em Space (\u2004),
Six-Per-Em Space (\u2006),
Figure Space (\u2007),
Punctuation Space (\u2008),
Thin Space (\u2009),
Hair Space (\u200A),
Zero Width Space (\u200B),
Narrow No-Break Space (\u202F),
Medium Mathematical Space (\u205F),
Ideographic Space (\u3000),
and Zero Width No-Break Space (\uFEFF).
In particular, it does not include carriage return (\r) or line feed (\n), which are covered by
ignoreLineEndingDifferences.
Exceptions
Thrown when the strings are not equivalent.
Equal(Memory<char>, Memory<char>)
Verifies that two strings are equivalent.
public static void Equal(Memory<char> expected, Memory<char> actual)
Parameters
Exceptions
Thrown when the strings are not equivalent.
Equal(Memory<char>, ReadOnlyMemory<char>)
Verifies that two strings are equivalent.
public static void Equal(Memory<char> expected, ReadOnlyMemory<char> actual)
Parameters
expectedMemory<char>The expected string value.
actualReadOnlyMemory<char>The actual string value.
Exceptions
Thrown when the strings are not equivalent.
Equal(ReadOnlyMemory<char>, Memory<char>)
Verifies that two strings are equivalent.
public static void Equal(ReadOnlyMemory<char> expected, Memory<char> actual)
Parameters
expectedReadOnlyMemory<char>The expected string value.
actualMemory<char>The actual string value.
Exceptions
Thrown when the strings are not equivalent.
Equal(ReadOnlyMemory<char>, ReadOnlyMemory<char>)
Verifies that two strings are equivalent.
public static void Equal(ReadOnlyMemory<char> expected, ReadOnlyMemory<char> actual)
Parameters
expectedReadOnlyMemory<char>The expected string value.
actualReadOnlyMemory<char>The actual string value.
Exceptions
Thrown when the strings are not equivalent.
Equal(Memory<char>, Memory<char>, bool, bool, bool, bool)
Verifies that two strings are equivalent.
public static void Equal(Memory<char> expected, Memory<char> actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)
Parameters
expectedMemory<char>The expected string value.
actualMemory<char>The actual string value.
ignoreCaseboolIf set to
true, ignores cases differences. The invariant culture is used.ignoreLineEndingDifferencesboolIf set to
true, treats \r\n, \r, and \n as equivalent.ignoreWhiteSpaceDifferencesboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.ignoreAllWhiteSpaceboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks), including zero quantities, as equivalent.
Remarks
The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider
the following characters to be white-space:
Tab (\t),
Space (\u0020),
No-Break Space (\u00A0),
Ogham Space Mark (\u1680),
Mongolian Vowel Separator (\u180E),
En Quad (\u2000),
Em Quad (\u2001),
En Space (\u2002),
Em Space (\u2003),
Three-Per-Em Space (\u2004),
Four-Per-Em Space (\u2004),
Six-Per-Em Space (\u2006),
Figure Space (\u2007),
Punctuation Space (\u2008),
Thin Space (\u2009),
Hair Space (\u200A),
Zero Width Space (\u200B),
Narrow No-Break Space (\u202F),
Medium Mathematical Space (\u205F),
Ideographic Space (\u3000),
and Zero Width No-Break Space (\uFEFF).
In particular, it does not include carriage return (\r) or line feed (\n), which are covered by
ignoreLineEndingDifferences.
Exceptions
Thrown when the strings are not equivalent.
Equal(Memory<char>, ReadOnlyMemory<char>, bool, bool, bool, bool)
Verifies that two strings are equivalent.
public static void Equal(Memory<char> expected, ReadOnlyMemory<char> actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)
Parameters
expectedMemory<char>The expected string value.
actualReadOnlyMemory<char>The actual string value.
ignoreCaseboolIf set to
true, ignores cases differences. The invariant culture is used.ignoreLineEndingDifferencesboolIf set to
true, treats \r\n, \r, and \n as equivalent.ignoreWhiteSpaceDifferencesboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.ignoreAllWhiteSpaceboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks), including zero quantities, as equivalent.
Remarks
The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider
the following characters to be white-space:
Tab (\t),
Space (\u0020),
No-Break Space (\u00A0),
Ogham Space Mark (\u1680),
Mongolian Vowel Separator (\u180E),
En Quad (\u2000),
Em Quad (\u2001),
En Space (\u2002),
Em Space (\u2003),
Three-Per-Em Space (\u2004),
Four-Per-Em Space (\u2004),
Six-Per-Em Space (\u2006),
Figure Space (\u2007),
Punctuation Space (\u2008),
Thin Space (\u2009),
Hair Space (\u200A),
Zero Width Space (\u200B),
Narrow No-Break Space (\u202F),
Medium Mathematical Space (\u205F),
Ideographic Space (\u3000),
and Zero Width No-Break Space (\uFEFF).
In particular, it does not include carriage return (\r) or line feed (\n), which are covered by
ignoreLineEndingDifferences.
Exceptions
Thrown when the strings are not equivalent.
Equal(ReadOnlyMemory<char>, Memory<char>, bool, bool, bool, bool)
Verifies that two strings are equivalent.
public static void Equal(ReadOnlyMemory<char> expected, Memory<char> actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)
Parameters
expectedReadOnlyMemory<char>The expected string value.
actualMemory<char>The actual string value.
ignoreCaseboolIf set to
true, ignores cases differences. The invariant culture is used.ignoreLineEndingDifferencesboolIf set to
true, treats \r\n, \r, and \n as equivalent.ignoreWhiteSpaceDifferencesboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.ignoreAllWhiteSpaceboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks), including zero quantities, as equivalent.
Remarks
The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider
the following characters to be white-space:
Tab (\t),
Space (\u0020),
No-Break Space (\u00A0),
Ogham Space Mark (\u1680),
Mongolian Vowel Separator (\u180E),
En Quad (\u2000),
Em Quad (\u2001),
En Space (\u2002),
Em Space (\u2003),
Three-Per-Em Space (\u2004),
Four-Per-Em Space (\u2004),
Six-Per-Em Space (\u2006),
Figure Space (\u2007),
Punctuation Space (\u2008),
Thin Space (\u2009),
Hair Space (\u200A),
Zero Width Space (\u200B),
Narrow No-Break Space (\u202F),
Medium Mathematical Space (\u205F),
Ideographic Space (\u3000),
and Zero Width No-Break Space (\uFEFF).
In particular, it does not include carriage return (\r) or line feed (\n), which are covered by
ignoreLineEndingDifferences.
Exceptions
Thrown when the strings are not equivalent.
Equal(ReadOnlyMemory<char>, ReadOnlyMemory<char>, bool, bool, bool, bool)
Verifies that two strings are equivalent.
public static void Equal(ReadOnlyMemory<char> expected, ReadOnlyMemory<char> actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)
Parameters
expectedReadOnlyMemory<char>The expected string value.
actualReadOnlyMemory<char>The actual string value.
ignoreCaseboolIf set to
true, ignores cases differences. The invariant culture is used.ignoreLineEndingDifferencesboolIf set to
true, treats \r\n, \r, and \n as equivalent.ignoreWhiteSpaceDifferencesboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.ignoreAllWhiteSpaceboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks), including zero quantities, as equivalent.
Remarks
The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider
the following characters to be white-space:
Tab (\t),
Space (\u0020),
No-Break Space (\u00A0),
Ogham Space Mark (\u1680),
Mongolian Vowel Separator (\u180E),
En Quad (\u2000),
Em Quad (\u2001),
En Space (\u2002),
Em Space (\u2003),
Three-Per-Em Space (\u2004),
Four-Per-Em Space (\u2004),
Six-Per-Em Space (\u2006),
Figure Space (\u2007),
Punctuation Space (\u2008),
Thin Space (\u2009),
Hair Space (\u200A),
Zero Width Space (\u200B),
Narrow No-Break Space (\u202F),
Medium Mathematical Space (\u205F),
Ideographic Space (\u3000),
and Zero Width No-Break Space (\uFEFF).
In particular, it does not include carriage return (\r) or line feed (\n), which are covered by
ignoreLineEndingDifferences.
Exceptions
Thrown when the strings are not equivalent.
Equal(Span<char>, Span<char>)
Verifies that two strings are equivalent.
public static void Equal(Span<char> expected, Span<char> actual)
Parameters
Exceptions
Thrown when the strings are not equivalent.
Equal(Span<char>, ReadOnlySpan<char>)
Verifies that two strings are equivalent.
public static void Equal(Span<char> expected, ReadOnlySpan<char> actual)
Parameters
expectedSpan<char>The expected string value.
actualReadOnlySpan<char>The actual string value.
Exceptions
Thrown when the strings are not equivalent.
Equal(ReadOnlySpan<char>, Span<char>)
Verifies that two strings are equivalent.
public static void Equal(ReadOnlySpan<char> expected, Span<char> actual)
Parameters
expectedReadOnlySpan<char>The expected string value.
actualSpan<char>The actual string value.
Exceptions
Thrown when the strings are not equivalent.
Equal(ReadOnlySpan<char>, ReadOnlySpan<char>)
Verifies that two strings are equivalent.
public static void Equal(ReadOnlySpan<char> expected, ReadOnlySpan<char> actual)
Parameters
expectedReadOnlySpan<char>The expected string value.
actualReadOnlySpan<char>The actual string value.
Exceptions
Thrown when the strings are not equivalent.
Equal(Span<char>, Span<char>, bool, bool, bool, bool)
Verifies that two strings are equivalent.
public static void Equal(Span<char> expected, Span<char> actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)
Parameters
expectedSpan<char>The expected string value.
actualSpan<char>The actual string value.
ignoreCaseboolIf set to
true, ignores cases differences. The invariant culture is used.ignoreLineEndingDifferencesboolIf set to
true, treats \r\n, \r, and \n as equivalent.ignoreWhiteSpaceDifferencesboolIf set to
true, treats spaces and tabs (in any non-zero quantity) as equivalent.ignoreAllWhiteSpaceboolIf set to
true, ignores all white space differences during comparison.
Remarks
The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider
the following characters to be white-space:
Tab (\t),
Space (\u0020),
No-Break Space (\u00A0),
Ogham Space Mark (\u1680),
Mongolian Vowel Separator (\u180E),
En Quad (\u2000),
Em Quad (\u2001),
En Space (\u2002),
Em Space (\u2003),
Three-Per-Em Space (\u2004),
Four-Per-Em Space (\u2004),
Six-Per-Em Space (\u2006),
Figure Space (\u2007),
Punctuation Space (\u2008),
Thin Space (\u2009),
Hair Space (\u200A),
Zero Width Space (\u200B),
Narrow No-Break Space (\u202F),
Medium Mathematical Space (\u205F),
Ideographic Space (\u3000),
and Zero Width No-Break Space (\uFEFF).
In particular, it does not include carriage return (\r) or line feed (\n), which are covered by
ignoreLineEndingDifferences.
Exceptions
Thrown when the strings are not equivalent.
Equal(Span<char>, ReadOnlySpan<char>, bool, bool, bool, bool)
Verifies that two strings are equivalent.
public static void Equal(Span<char> expected, ReadOnlySpan<char> actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)
Parameters
expectedSpan<char>The expected string value.
actualReadOnlySpan<char>The actual string value.
ignoreCaseboolIf set to
true, ignores cases differences. The invariant culture is used.ignoreLineEndingDifferencesboolIf set to
true, treats \r\n, \r, and \n as equivalent.ignoreWhiteSpaceDifferencesboolIf set to
true, treats spaces and tabs (in any non-zero quantity) as equivalent.ignoreAllWhiteSpaceboolIf set to
true, ignores all white space differences during comparison.
Remarks
The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider
the following characters to be white-space:
Tab (\t),
Space (\u0020),
No-Break Space (\u00A0),
Ogham Space Mark (\u1680),
Mongolian Vowel Separator (\u180E),
En Quad (\u2000),
Em Quad (\u2001),
En Space (\u2002),
Em Space (\u2003),
Three-Per-Em Space (\u2004),
Four-Per-Em Space (\u2004),
Six-Per-Em Space (\u2006),
Figure Space (\u2007),
Punctuation Space (\u2008),
Thin Space (\u2009),
Hair Space (\u200A),
Zero Width Space (\u200B),
Narrow No-Break Space (\u202F),
Medium Mathematical Space (\u205F),
Ideographic Space (\u3000),
and Zero Width No-Break Space (\uFEFF).
In particular, it does not include carriage return (\r) or line feed (\n), which are covered by
ignoreLineEndingDifferences.
Exceptions
Thrown when the strings are not equivalent.
Equal(ReadOnlySpan<char>, Span<char>, bool, bool, bool, bool)
Verifies that two strings are equivalent.
public static void Equal(ReadOnlySpan<char> expected, Span<char> actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)
Parameters
expectedReadOnlySpan<char>The expected string value.
actualSpan<char>The actual string value.
ignoreCaseboolIf set to
true, ignores cases differences. The invariant culture is used.ignoreLineEndingDifferencesboolIf set to
true, treats \r\n, \r, and \n as equivalent.ignoreWhiteSpaceDifferencesboolIf set to
true, treats spaces and tabs (in any non-zero quantity) as equivalent.ignoreAllWhiteSpaceboolIf set to
true, removes all whitespaces and tabs before comparing.
Remarks
The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider
the following characters to be white-space:
Tab (\t),
Space (\u0020),
No-Break Space (\u00A0),
Ogham Space Mark (\u1680),
Mongolian Vowel Separator (\u180E),
En Quad (\u2000),
Em Quad (\u2001),
En Space (\u2002),
Em Space (\u2003),
Three-Per-Em Space (\u2004),
Four-Per-Em Space (\u2004),
Six-Per-Em Space (\u2006),
Figure Space (\u2007),
Punctuation Space (\u2008),
Thin Space (\u2009),
Hair Space (\u200A),
Zero Width Space (\u200B),
Narrow No-Break Space (\u202F),
Medium Mathematical Space (\u205F),
Ideographic Space (\u3000),
and Zero Width No-Break Space (\uFEFF).
In particular, it does not include carriage return (\r) or line feed (\n), which are covered by
ignoreLineEndingDifferences.
Exceptions
Thrown when the strings are not equivalent.
Equal(string?, string?, bool, bool, bool, bool)
Verifies that two strings are equivalent.
public static void Equal(string? expected, string? actual, bool ignoreCase = false, bool ignoreLineEndingDifferences = false, bool ignoreWhiteSpaceDifferences = false, bool ignoreAllWhiteSpace = false)
Parameters
expectedstringThe expected string value.
actualstringThe actual string value.
ignoreCaseboolIf set to
true, ignores cases differences. The invariant culture is used.ignoreLineEndingDifferencesboolIf set to
true, treats \r\n, \r, and \n as equivalent.ignoreWhiteSpaceDifferencesboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.ignoreAllWhiteSpaceboolIf set to
true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks), including zero quantities, as equivalent.
Remarks
The ignoreWhiteSpaceDifferences and ignoreAllWhiteSpace flags consider
the following characters to be white-space:
Tab (\t),
Space (\u0020),
No-Break Space (\u00A0),
Ogham Space Mark (\u1680),
Mongolian Vowel Separator (\u180E),
En Quad (\u2000),
Em Quad (\u2001),
En Space (\u2002),
Em Space (\u2003),
Three-Per-Em Space (\u2004),
Four-Per-Em Space (\u2004),
Six-Per-Em Space (\u2006),
Figure Space (\u2007),
Punctuation Space (\u2008),
Thin Space (\u2009),
Hair Space (\u200A),
Zero Width Space (\u200B),
Narrow No-Break Space (\u202F),
Medium Mathematical Space (\u205F),
Ideographic Space (\u3000),
and Zero Width No-Break Space (\uFEFF).
In particular, it does not include carriage return (\r) or line feed (\n), which are covered by
ignoreLineEndingDifferences.
Exceptions
Thrown when the strings are not equivalent.