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

32 lines
1 KiB
C#
Raw Normal View History

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