1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-05 14:59:09 +01:00
MLEM/Tests/CollectionTests.cs

31 lines
1.1 KiB
C#
Raw Normal View History

2021-03-18 18:31:59 +01:00
using MLEM.Extensions;
using NUnit.Framework;
namespace Tests {
public class CollectionTests {
[Test]
public void TestCombinations() {
var things = new[] {
new[] {'1', '2', '3'},
new[] {'A', 'B'},
new[] {'+', '-'}
};
2021-03-18 18:31:59 +01: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
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);
}
}
}