public void ConstructorTest() { int size = 4; Permutor permutor = new Permutor(size); int[] current = permutor.GetCurrentPermutation(); Assert.IsTrue(Compares.AreEqual(GetIdentity(size), current)); }
public void SetPermutationTest() { int size = 4; int[] target = new int[] { 3, 1, 0, 2 }; Permutor permutor = new Permutor(size); permutor.SetPermutation(target); Assert.IsTrue(Compares.AreEqual(target, permutor.GetCurrentPermutation())); }
public void SetRankTest() { int size = 4; int[] reverse = new int[] { 3, 2, 1, 0 }; Permutor permutor = new Permutor(size); // out of 4! = 24 permutations, numbered 0-23, this is the last permutor.Rank = 23; Assert.IsTrue(Compares.AreEqual(reverse, permutor.GetCurrentPermutation())); }
public void GetCurrentPermutationTest() { int size = 4; Permutor permutor = new Permutor(size); bool allOk = true; while (permutor.HasNext()) { permutor.GetNextPermutation(); int[] current = permutor.GetCurrentPermutation(); if (ArrayElementsDistinct(current)) { continue; } else { allOk = false; break; } } Assert.IsTrue(allOk); }