2021-03-18 18:31:59 +01:00
|
|
|
using MLEM.Extensions;
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
2022-10-27 10:22:25 +02:00
|
|
|
namespace Tests;
|
2021-03-18 18:31:59 +01:00
|
|
|
|
2022-10-27 10:22:25 +02:00
|
|
|
public class CollectionTests {
|
2021-03-24 22:44:39 +01:00
|
|
|
|
2022-10-27 10:22:25 +02:00
|
|
|
[Test]
|
|
|
|
public void TestCombinations() {
|
|
|
|
var things = new[] {
|
|
|
|
new[] {'1', '2', '3'},
|
|
|
|
new[] {'A', 'B'},
|
|
|
|
new[] {'+', '-'}
|
|
|
|
};
|
2021-03-24 22:44:39 +01:00
|
|
|
|
2022-10-27 10:22:25 +02:00
|
|
|
var expected = new[] {
|
|
|
|
new[] {'1', 'A', '+'}, new[] {'1', 'A', '-'}, new[] {'1', 'B', '+'}, new[] {'1', 'B', '-'},
|
|
|
|
new[] {'2', 'A', '+'}, new[] {'2', 'A', '-'}, new[] {'2', 'B', '+'}, new[] {'2', 'B', '-'},
|
|
|
|
new[] {'3', 'A', '+'}, new[] {'3', 'A', '-'}, new[] {'3', 'B', '+'}, new[] {'3', 'B', '-'}
|
|
|
|
};
|
|
|
|
Assert.AreEqual(things.Combinations(), expected);
|
2021-03-18 18:31:59 +01:00
|
|
|
|
2022-10-27 10:22:25 +02:00
|
|
|
var indices = new[] {
|
|
|
|
new[] {0, 0, 0}, new[] {0, 0, 1}, new[] {0, 1, 0}, new[] {0, 1, 1},
|
|
|
|
new[] {1, 0, 0}, new[] {1, 0, 1}, new[] {1, 1, 0}, new[] {1, 1, 1},
|
|
|
|
new[] {2, 0, 0}, new[] {2, 0, 1}, new[] {2, 1, 0}, new[] {2, 1, 1}
|
|
|
|
};
|
|
|
|
Assert.AreEqual(things.IndexCombinations(), indices);
|
2021-03-18 18:31:59 +01:00
|
|
|
}
|
2022-10-27 10:22:25 +02:00
|
|
|
|
2022-06-17 18:23:47 +02:00
|
|
|
}
|