Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Commit

Permalink
Cleanup ImmutableArray tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesqo committed Jan 7, 2017
1 parent 3941265 commit 295ce63
Show file tree
Hide file tree
Showing 4 changed files with 1,701 additions and 866 deletions.
36 changes: 36 additions & 0 deletions src/Common/tests/System/Collections/DelegateEqualityComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;

namespace System.Collections.Tests
{
internal sealed class DelegateEqualityComparer<T> : IEqualityComparer<T>, IEqualityComparer
{
private readonly Func<T, T, bool> _equals;
private readonly Func<T, int> _getHashCode;
private readonly Func<object, object, bool> _objectEquals;
private readonly Func<object, int> _objectGetHashCode;

public DelegateEqualityComparer(
Func<T, T, bool> equals = null,
Func<T, int> getHashCode = null,
Func<object, object, bool> objectEquals = null,
Func<object, int> objectGetHashCode = null)
{
_equals = equals ?? ((x, y) => { throw new NotImplementedException(); });
_getHashCode = getHashCode ?? (obj => { throw new NotImplementedException(); });
_objectEquals = objectEquals ?? ((x, y) => { throw new NotImplementedException(); });
_objectGetHashCode = objectGetHashCode ?? (obj => { throw new NotImplementedException(); });
}

public bool Equals(T x, T y) => _equals(x, y);

public int GetHashCode(T obj) => _getHashCode(obj);

bool IEqualityComparer.Equals(object x, object y) => _objectEquals(x, y);

int IEqualityComparer.GetHashCode(object obj) => _objectGetHashCode(obj);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public bool IsEmpty
}

/// <summary>
/// Gets the number of array in the collection.
/// Gets the number of elements in the array.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public int Length
Expand Down
Loading

0 comments on commit 295ce63

Please sign in to comment.