mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-14 12:15:05 +00:00
Extension methods for padding lists
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
using ICD.Common.Utils.Extensions;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace ICD.Common.Utils.Tests.Extensions
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class ListExtensionsTest
|
||||
{
|
||||
public sealed class ListExtensionsTest
|
||||
{
|
||||
[Test]
|
||||
public void AddSortedTest()
|
||||
{
|
||||
@@ -43,7 +43,83 @@ namespace ICD.Common.Utils.Tests.Extensions
|
||||
Assert.AreEqual(1, testList[3]);
|
||||
}
|
||||
|
||||
internal class InverseComparer : IComparer<int>
|
||||
[Test]
|
||||
public void PadRightTest()
|
||||
{
|
||||
List<int> testList = new List<int>();
|
||||
testList.PadRight(10);
|
||||
|
||||
Assert.AreEqual(10, testList.Count);
|
||||
Assert.AreEqual(0, testList.Sum());
|
||||
|
||||
testList = new List<int>
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
};
|
||||
|
||||
testList.PadRight(10);
|
||||
|
||||
Assert.AreEqual(10, testList.Count);
|
||||
Assert.AreEqual(15, testList.Sum());
|
||||
|
||||
testList = new List<int>
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
};
|
||||
|
||||
testList.PadRight(1);
|
||||
|
||||
Assert.AreEqual(5, testList.Count);
|
||||
Assert.AreEqual(15, testList.Sum());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PadRightDefaultTest()
|
||||
{
|
||||
List<int> testList = new List<int>();
|
||||
testList.PadRight(10, 1);
|
||||
|
||||
Assert.AreEqual(10, testList.Count);
|
||||
Assert.AreEqual(10, testList.Sum());
|
||||
|
||||
testList = new List<int>
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
};
|
||||
|
||||
testList.PadRight(10, 1);
|
||||
|
||||
Assert.AreEqual(10, testList.Count);
|
||||
Assert.AreEqual(20, testList.Sum());
|
||||
|
||||
testList = new List<int>
|
||||
{
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
5
|
||||
};
|
||||
|
||||
testList.PadRight(1, 1);
|
||||
|
||||
Assert.AreEqual(5, testList.Count);
|
||||
Assert.AreEqual(15, testList.Sum());
|
||||
}
|
||||
|
||||
private sealed class InverseComparer : IComparer<int>
|
||||
{
|
||||
public int Compare(int x, int y)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user