-
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 #7 from pfpack/release/v1.0.2-rc.1
release/v1.0.2-rc.1
- Loading branch information
Showing
63 changed files
with
1,106 additions
and
1,377 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
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
5 changes: 5 additions & 0 deletions
5
...arers/Collections.Generic.EqualityComparers.Tests/Array/ArrayEqualityComparer_RefTests.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,5 @@ | ||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
public sealed class ArrayEqualityComparer_RefTests : ArrayEqualityComparer_TestsBase<string?> | ||
{ | ||
} |
5 changes: 5 additions & 0 deletions
5
...rs/Collections.Generic.EqualityComparers.Tests/Array/ArrayEqualityComparer_StructTests.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,5 @@ | ||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
public sealed class ArrayEqualityComparer_StructTests : ArrayEqualityComparer_TestsBase<int?> | ||
{ | ||
} |
97 changes: 97 additions & 0 deletions
97
...rers/Collections.Generic.EqualityComparers.Tests/Array/ArrayEqualityComparer_TestsBase.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,97 @@ | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace PrimeFuncPack.Collections.Generic.EqualityComparers.Tests; | ||
|
||
public abstract class ArrayEqualityComparer_TestsBase<T> | ||
{ | ||
[Theory] | ||
[MemberData(nameof(Test_Factory_ExpectItemComparer_Cases))] | ||
public static void Test_Factory_ExpectItemComparer(ArrayEqualityComparer<T> comparer, IEqualityComparer<T> expected) | ||
=> | ||
FactoryAssert.AssertItemComparer(comparer, expected); | ||
|
||
[Fact] | ||
public static void Test_GetHashCode_InputIsNull_ExpectZero() | ||
{ | ||
var comparer = BuildComparer(); | ||
T[]? nullObj = null; | ||
var actual = comparer.GetHashCode(nullObj); | ||
Assert.StrictEqual(0, actual); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(InputsAreEqualCases))] | ||
public static void Test_GetHashCode_InputsAreEqual_ExpectHashCodesAreEqual(CaseParamOfArray<T> input1, CaseParamOfArray<T> input2) | ||
{ | ||
var comparer = BuildComparer(); | ||
var hashCode1 = comparer.GetHashCode(input1.Items); | ||
var hashCode2 = comparer.GetHashCode(input2.Items); | ||
Assert.StrictEqual(hashCode1, hashCode2); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(InputsAreEqualCases))] | ||
public static void Test_Equals_InputsAreEqual_ExpectTrue(CaseParamOfArray<T> input1, CaseParamOfArray<T> input2) | ||
{ | ||
var comparer = BuildComparer(); | ||
var actualEquals = comparer.Equals(input1.Items, input2.Items); | ||
Assert.True(actualEquals); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(InputsAreNotEqualCases))] | ||
public static void Test_Equals_InputsAreNotEqual_ExpectTrue(CaseParamOfArray<T> input1, CaseParamOfArray<T> input2) | ||
{ | ||
var comparer = BuildComparer(); | ||
var actualEquals = comparer.Equals(input1.Items, input2.Items); | ||
Assert.False(actualEquals); | ||
} | ||
|
||
public static TheoryData<ArrayEqualityComparer<T>, IEqualityComparer<T>> Test_Factory_ExpectItemComparer_Cases => new() | ||
{ | ||
{ | ||
ArrayEqualityComparer<T>.Default, | ||
EqualityComparer<T>.Default | ||
}, | ||
{ | ||
ArrayEqualityComparer<T>.Create(), | ||
EqualityComparer<T>.Default | ||
}, | ||
{ | ||
ArrayEqualityComparer<T>.Create(null), | ||
EqualityComparer<T>.Default | ||
}, | ||
{ | ||
ArrayEqualityComparer<T>.Create(EqualityComparer<T>.Default), | ||
EqualityComparer<T>.Default | ||
}, | ||
{ | ||
ArrayEqualityComparer<T>.Create(CustomEqualityComparer<T>.Default), | ||
CustomEqualityComparer<T>.Default | ||
}, | ||
}; | ||
|
||
public static TheoryData<CaseParamOfArray<T>, CaseParamOfArray<T>> InputsAreEqualCases() | ||
=> | ||
MapEqualsCases(CaseSources.EqualArrays<T>()); | ||
|
||
public static TheoryData<CaseParamOfArray<T>, CaseParamOfArray<T>> InputsAreNotEqualCases() | ||
=> | ||
MapEqualsCases(CaseSources.NotEqualArrays<T>()); | ||
|
||
private static ArrayEqualityComparer<T> BuildComparer() | ||
=> | ||
ArrayEqualityComparer<T>.Create(CustomEqualityComparer<T>.Default); | ||
|
||
private static TheoryData<CaseParamOfArray<T>, CaseParamOfArray<T>> MapEqualsCases( | ||
IEnumerable<(T[]? X, T[]? Y)> cases) | ||
{ | ||
var result = new TheoryData<CaseParamOfArray<T>, CaseParamOfArray<T>>(); | ||
foreach (var (X, Y) in cases) | ||
{ | ||
result.Add(new(X), new(Y)); | ||
} | ||
return result; | ||
} | ||
} |
45 changes: 0 additions & 45 deletions
45
...ons.Generic.EqualityComparers.Tests/ArrayEqualityComparer/EqualityComparerTestsFactory.cs
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
...ons.Generic.EqualityComparers.Tests/ArrayEqualityComparer/EqualityComparerTestsGeneral.cs
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
...ections.Generic.EqualityComparers.Tests/ArrayEqualityComparer/EqualityComparerTestsRef.cs
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
...ions.Generic.EqualityComparers.Tests/ArrayEqualityComparer/EqualityComparerTestsStruct.cs
This file was deleted.
Oops, something went wrong.
70 changes: 0 additions & 70 deletions
70
...tions-generic-equalitycomparers/Collections.Generic.EqualityComparers.Tests/CaseMapper.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.