-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from pfpack/release/v1.0.2
release/v1.0.2
- Loading branch information
Showing
29 changed files
with
573 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...ic.EqualityComparers.Tests/CaseSources/EqualCaseSource.InnerEqualArraysOfInt32Nullable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#pragma warning disable IDE0300 // Simplify collection initialization | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
partial class EqualCaseSource | ||
{ | ||
private static IEnumerable<(int?[]? X, int?[]? Y)> InnerEqualArraysOfInt32Nullable() | ||
{ | ||
// Equal by reference | ||
|
||
yield return ( | ||
null, | ||
null | ||
); | ||
yield return ( | ||
EmptyArray<int?>.Value, | ||
EmptyArray<int?>.Value | ||
); | ||
var array1 = new int?[] { 1 }; | ||
var array2 = new int?[] { 1, 2 }; | ||
var array3 = new int?[] { 1, 2, 3 }; | ||
var array4 = new int?[] { 1, 2, 3, 4 }; | ||
yield return ( | ||
array1, | ||
array1 | ||
); | ||
yield return ( | ||
array2, | ||
array2 | ||
); | ||
yield return ( | ||
array3, | ||
array3 | ||
); | ||
yield return ( | ||
array4, | ||
array4 | ||
); | ||
|
||
// Equal by value | ||
|
||
yield return ( | ||
new int?[] { null }, | ||
new int?[] { null } | ||
); | ||
yield return ( | ||
EmptyArray<int?>.Create(), | ||
EmptyArray<int?>.Create() | ||
); | ||
yield return ( | ||
new int?[] { 1 }, | ||
new int?[] { 1 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2 }, | ||
new int?[] { 1, 2 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2, 3 }, | ||
new int?[] { 1, 2, 3 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2, 3, 4 }, | ||
new int?[] { 1, 2, 3, 4 } | ||
); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...s.Generic.EqualityComparers.Tests/CaseSources/EqualCaseSource.InnerEqualArraysOfString.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#pragma warning disable IDE0300 // Simplify collection initialization | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
partial class EqualCaseSource | ||
{ | ||
private static IEnumerable<(string?[]? X, string?[]? Y)> InnerEqualArraysOfString() | ||
{ | ||
// Equal by reference | ||
|
||
yield return ( | ||
null, | ||
null | ||
); | ||
yield return ( | ||
EmptyArray<string>.Value, | ||
EmptyArray<string>.Value | ||
); | ||
var array1 = new[] { "1" }; | ||
var array2 = new[] { "1", "2" }; | ||
var array3 = new[] { "1", "2", "3" }; | ||
var array4 = new[] { "1", "2", "3", "4" }; | ||
yield return ( | ||
array1, | ||
array1 | ||
); | ||
yield return ( | ||
array2, | ||
array2 | ||
); | ||
yield return ( | ||
array3, | ||
array3 | ||
); | ||
yield return ( | ||
array4, | ||
array4 | ||
); | ||
|
||
// Equal by value | ||
|
||
yield return ( | ||
new[] { (string?)null }, | ||
new[] { (string?)null } | ||
); | ||
yield return ( | ||
EmptyArray<string>.Create(), | ||
EmptyArray<string>.Create() | ||
); | ||
yield return ( | ||
new[] { "1" }, | ||
new[] { "1" } | ||
); | ||
yield return ( | ||
new[] { "1", "2" }, | ||
new[] { "1", "2" } | ||
); | ||
yield return ( | ||
new[] { "1", "2", "3" }, | ||
new[] { "1", "2", "3" } | ||
); | ||
yield return ( | ||
new[] { "1", "2", "3", "4" }, | ||
new[] { "1", "2", "3", "4" } | ||
); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...alitycomparers/Collections.Generic.EqualityComparers.Tests/CaseSources/EqualCaseSource.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
internal static partial class EqualCaseSource | ||
{ | ||
internal static IEnumerable<(T[]? X, T[]? Y)> EqualArrays<T>() | ||
{ | ||
if (typeof(T) == typeof(string)) | ||
{ | ||
return (IEnumerable<(T[]? X, T[]? Y)>)InnerEqualArraysOfString(); | ||
} | ||
|
||
if (typeof(T) == typeof(int?)) | ||
{ | ||
return (IEnumerable<(T[]? X, T[]? Y)>)InnerEqualArraysOfInt32Nullable(); | ||
} | ||
|
||
throw new ArgumentException($"An unexpected type ({typeof(T).Name}).", nameof(T)); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...mparers.Tests/CaseSources/NotEqualCaseSource_Equals.InnerNotEqualArraysOfInt32Nullable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#pragma warning disable IDE0300 // Simplify collection initialization | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
partial class NotEqualCaseSource_Equals | ||
{ | ||
private static IEnumerable<(int?[]? X, int?[]? Y)> InnerNotEqualArraysOfInt32Nullable() | ||
{ | ||
yield return ( | ||
null, | ||
EmptyArray<int?>.Value); | ||
yield return ( | ||
null, | ||
new int?[] { 1 } | ||
); | ||
yield return ( | ||
EmptyArray<int?>.Value, | ||
new int?[] { 1 } | ||
); | ||
yield return ( | ||
new int?[] { 1 }, | ||
new int?[] { 1, 2 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2 }, | ||
new int?[] { 1, 2, 3 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2, 3 }, | ||
new int?[] { 1, 2, 3, 4 } | ||
); | ||
yield return ( | ||
new int?[] { null }, | ||
new int?[] { 0 } | ||
); | ||
yield return ( | ||
new int?[] { null }, | ||
new int?[] { 1 } | ||
); | ||
yield return ( | ||
new int?[] { 1 }, | ||
new int?[] { 2 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2 }, | ||
new int?[] { 1, 1 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2, 3 }, | ||
new int?[] { 1, 0, 3 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2, 3, 4 }, | ||
new int?[] { 0, 2, 3, 4 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2, 3, 4 }, | ||
new int?[] { 1, 1, 3, 4 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2, 3, 4 }, | ||
new int?[] { 1, 2, 2, 4 } | ||
); | ||
yield return ( | ||
new int?[] { 1, 2, 3, 4 }, | ||
new int?[] { 1, 2, 3, 3 } | ||
); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...alityComparers.Tests/CaseSources/NotEqualCaseSource_Equals.InnerNotEqualArraysOfString.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#pragma warning disable IDE0300 // Simplify collection initialization | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
partial class NotEqualCaseSource_Equals | ||
{ | ||
private static IEnumerable<(string?[]? X, string?[]? Y)> InnerNotEqualArraysOfString() | ||
{ | ||
yield return ( | ||
null, | ||
EmptyArray<string>.Value); | ||
yield return ( | ||
null, | ||
new[] { "1" } | ||
); | ||
yield return ( | ||
EmptyArray<string>.Value, | ||
new[] { "1" } | ||
); | ||
yield return ( | ||
new[] { "1" }, | ||
new[] { "1", "2" } | ||
); | ||
yield return ( | ||
new[] { "1", "2" }, | ||
new[] { "1", "2", "3" } | ||
); | ||
yield return ( | ||
new[] { "1", "2", "3" }, | ||
new[] { "1", "2", "3", "4" } | ||
); | ||
yield return ( | ||
new[] { (string?)null }, | ||
new[] { "" } | ||
); | ||
yield return ( | ||
new[] { (string?)null }, | ||
new[] { "1" } | ||
); | ||
yield return ( | ||
new[] { "1" }, | ||
new[] { "2" } | ||
); | ||
yield return ( | ||
new[] { "1", "2" }, | ||
new[] { "1", "1" } | ||
); | ||
yield return ( | ||
new[] { "1", "2", "3" }, | ||
new[] { "1", "0", "3" } | ||
); | ||
yield return ( | ||
new[] { "1", "2", "3", "4" }, | ||
new[] { "0", "2", "3", "4" } | ||
); | ||
yield return ( | ||
new[] { "1", "2", "3", "4" }, | ||
new[] { "1", "1", "3", "4" } | ||
); | ||
yield return ( | ||
new[] { "1", "2", "3", "4" }, | ||
new[] { "1", "2", "2", "4" } | ||
); | ||
yield return ( | ||
new[] { "1", "2", "3", "4" }, | ||
new[] { "1", "2", "3", "3" } | ||
); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...rers/Collections.Generic.EqualityComparers.Tests/CaseSources/NotEqualCaseSource_Equals.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
internal static partial class NotEqualCaseSource_Equals | ||
{ | ||
internal static IEnumerable<(T[]? X, T[]? Y)> NotEqualArrays<T>() | ||
=> | ||
InnerNotEqualArrays<T>().ToArray() switch | ||
{ | ||
var pairs => pairs.Concat(pairs.Select(pair => (pair.Y, pair.X))) | ||
}; | ||
|
||
private static IEnumerable<(T[]? X, T[]? Y)> InnerNotEqualArrays<T>() | ||
{ | ||
if (typeof(T) == typeof(string)) | ||
{ | ||
return (IEnumerable<(T[]? X, T[]? Y)>)InnerNotEqualArraysOfString(); | ||
} | ||
|
||
if (typeof(T) == typeof(int?)) | ||
{ | ||
return (IEnumerable<(T[]? X, T[]? Y)>)InnerNotEqualArraysOfInt32Nullable(); | ||
} | ||
|
||
throw new ArgumentException($"An unexpected type ({typeof(T).Name}).", nameof(T)); | ||
} | ||
} |
Oops, something went wrong.