commit
This commit is contained in:
77
Assets/Tests/Editor/TestBitWise.cs
Normal file
77
Assets/Tests/Editor/TestBitWise.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Assets.Data
|
||||
{
|
||||
[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,
|
||||
0b00111,
|
||||
}
|
||||
);
|
||||
yield return new TestCaseData(
|
||||
1,
|
||||
1,
|
||||
new HashSet<long>()
|
||||
{
|
||||
0b001
|
||||
}
|
||||
);
|
||||
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
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user