Table of Contents

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

expected IEnumerable<T>

The expected value

actual IEnumerable<T>

The value to be compared against

Type Parameters

T

The 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

expected IEnumerable<T>

The expected value

actual IEnumerable<T>

The value to be compared against

comparer IEqualityComparer<T>

The comparer used to compare the two objects

Type Parameters

T

The 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

expected IEnumerable<T>

The expected value

actual IEnumerable<T>

The value to be compared against

comparer Func<T, T, bool>

The function to compare two items for equality

Type Parameters

T

The 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

expected T[]

The expected value

actual T[]

The value to be compared against

Type Parameters

T

The 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

expected T

The expected value

actual T

The value to be compared against

Type Parameters

T

The 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

expected T

The expected value

actual T

The value to be compared against

comparer Func<T, T, bool>

The comparer used to compare the two objects

Type Parameters

T

The 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

expected T

The expected value

actual T

The value to be compared against

comparer IEqualityComparer<T>

The comparer used to compare the two objects

Type Parameters

T

The 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

expected double

The expected value

actual double

The value to be compared against

precision int

The 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

expected double

The expected value

actual double

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

rounding MidpointRounding

Rounding 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

expected double

The expected value

actual double

The value to be compared against

tolerance double

The 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

expected float

The expected value

actual float

The value to be compared against

precision int

The 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

expected float

The expected value

actual float

The value to be compared against

precision int

The number of decimal places (valid values: 0-15)

rounding MidpointRounding

Rounding 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

expected float

The expected value

actual float

The value to be compared against

tolerance float

The 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

expected decimal

The expected value

actual decimal

The value to be compared against

precision int

The 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

expected DateTime

The expected value

actual DateTime

The value to be compared against

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

expected DateTime

The expected value

actual DateTime

The value to be compared against

precision TimeSpan

The 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

expected DateTimeOffset

The expected value

actual DateTimeOffset

The 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

expected DateTimeOffset

The expected value

actual DateTimeOffset

The value to be compared against

precision TimeSpan

The 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

expectedMemory Memory<T>

The expected Memory value.

actualMemory Memory<T>

The actual Memory value.

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

expectedMemory Memory<T>

The expected Memory value.

actualMemory ReadOnlyMemory<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

expectedMemory ReadOnlyMemory<T>

The expected Memory value.

actualMemory Memory<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

expectedMemory ReadOnlyMemory<T>

The expected Memory value.

actualMemory ReadOnlyMemory<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

expectedSpan ReadOnlySpan<T>

The expected span value.

actualArray T[]

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

expectedSpan Span<T>

The expected span value.

actualSpan Span<T>

The actual span value.

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

expectedSpan Span<T>

The expected span value.

actualSpan ReadOnlySpan<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

expectedSpan ReadOnlySpan<T>

The expected span value.

actualSpan Span<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

expectedSpan ReadOnlySpan<T>

The expected span value.

actualSpan ReadOnlySpan<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

expected string

The expected string value.

actual string

The actual string value.

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

expected ReadOnlySpan<char>

The expected string value.

actual ReadOnlySpan<char>

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.

ignoreAllWhiteSpace bool

If 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

expected Memory<char>

The expected string value.

actual Memory<char>

The actual string value.

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

expected Memory<char>

The expected string value.

actual ReadOnlyMemory<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

expected ReadOnlyMemory<char>

The expected string value.

actual Memory<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

expected ReadOnlyMemory<char>

The expected string value.

actual ReadOnlyMemory<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

expected Memory<char>

The expected string value.

actual Memory<char>

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.

ignoreAllWhiteSpace bool

If 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

expected Memory<char>

The expected string value.

actual ReadOnlyMemory<char>

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.

ignoreAllWhiteSpace bool

If 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

expected ReadOnlyMemory<char>

The expected string value.

actual Memory<char>

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.

ignoreAllWhiteSpace bool

If 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

expected ReadOnlyMemory<char>

The expected string value.

actual ReadOnlyMemory<char>

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.

ignoreAllWhiteSpace bool

If 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

expected Span<char>

The expected string value.

actual Span<char>

The actual string value.

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

expected Span<char>

The expected string value.

actual ReadOnlySpan<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

expected ReadOnlySpan<char>

The expected string value.

actual Span<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

expected ReadOnlySpan<char>

The expected string value.

actual ReadOnlySpan<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

expected Span<char>

The expected string value.

actual Span<char>

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats spaces and tabs (in any non-zero quantity) as equivalent.

ignoreAllWhiteSpace bool

If 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

expected Span<char>

The expected string value.

actual ReadOnlySpan<char>

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats spaces and tabs (in any non-zero quantity) as equivalent.

ignoreAllWhiteSpace bool

If 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

expected ReadOnlySpan<char>

The expected string value.

actual Span<char>

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats spaces and tabs (in any non-zero quantity) as equivalent.

ignoreAllWhiteSpace bool

If 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

expected string

The expected string value.

actual string

The actual string value.

ignoreCase bool

If set to true, ignores cases differences. The invariant culture is used.

ignoreLineEndingDifferences bool

If set to true, treats \r\n, \r, and \n as equivalent.

ignoreWhiteSpaceDifferences bool

If set to true, treats horizontal white-space (i.e. spaces, tabs, and others; see remarks) in any non-zero quantity as equivalent.

ignoreAllWhiteSpace bool

If 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.