Files
TraitTracker/Assets/Tests/Editor/TestBitWise.cs

92 lines
2.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
namespace Tests.Editor
{
[TestFixture]
public class TestBitWise
{
[Test]
[TestCaseSource(typeof(BitwiseCase), "BitwiseCombination")]
public void TestBitwiseCombination(int n, int p, HashSet<long> expected)
{
HashSet<long> output = BitWise.GetAllPermutation(n, p);
Assert.IsTrue(output.SetEquals(expected));
}
}
public class BitwiseCase
{
public static IEnumerable BitwiseCombination
{
get
{
yield return new TestCaseData(
3,
5,
new HashSet<long>()
{
0b11100,
0b11010,
0b10110,
0b01110,
0b11001,
0b10101,
0b01101,
0b10011,
0b01011,
7,
}
);
yield return new TestCaseData(
1,
1,
new HashSet<long>()
{
0b001
}
);
yield return new TestCaseData(
0,
1,
new HashSet<long>()
{
0b0
}
);
yield return new TestCaseData(
3,
1,
new HashSet<long>()
{
}
);
yield return new TestCaseData(
2,
3,
new HashSet<long>()
{
0b011,
0b110,
0b101
}
);
yield return new TestCaseData(
2,
4,
new HashSet<long>()
{
0b0011,
0b0101,
0b1001,
0b0110,
0b1010,
0b1100
}
);
}
}
}
}