Skip to content

Commit

Permalink
Merge pull request #7 from pfpack/release/v1.0.2-rc.1
Browse files Browse the repository at this point in the history
release/v1.0.2-rc.1
  • Loading branch information
andreise authored Dec 28, 2024
2 parents 24f6c40 + 4a53bcf commit 1bb18db
Show file tree
Hide file tree
Showing 63 changed files with 1,106 additions and 1,377 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
9.0.x
# Create Local NuGet Source

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ StyleCopReport.xml
*.pgc
*.pgd
*.rsp
# but not Directory.Build.rsp, as it configures directory-level build defaults
!Directory.Build.rsp
*.sbr
*.tlb
*.tli
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022-2023 Andrei Sergeev, Pavel Moskovoy
Copyright (c) 2022-2024 Andrei Sergeev, Pavel Moskovoy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
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?>
{
}
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?>
{
}
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;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 1bb18db

Please sign in to comment.