diff --git a/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java b/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java index 3c7a83d88..b077d5a81 100644 --- a/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java +++ b/src/test/java/org/apache/commons/math3/util/CombinatoricsUtilsTest.java @@ -379,6 +379,9 @@ public class CombinatoricsUtilsTest { combinationsIterator = CombinatoricsUtils.combinationsIterator(0, 0); checkIterator(combinationsIterator, 0, 0); combinationsIterator = CombinatoricsUtils.combinationsIterator(4, 2); + checkIterator(combinationsIterator, 4, 2); + combinationsIterator = CombinatoricsUtils.combinationsIterator(123, 2); + checkIterator(combinationsIterator, 123, 2); } /** @@ -386,8 +389,6 @@ public class CombinatoricsUtilsTest { * increasing sequence of b(n,k) arrays, each having length k * and each array itself increasing. * - * Note: the lexicographic order check only works for n < 10. - * * @param iterator * @param n size of universe * @param k size of subsets @@ -398,7 +399,7 @@ public class CombinatoricsUtilsTest { while (iterator.hasNext()) { final int[] iterate = iterator.next(); Assert.assertEquals(k, iterate.length); - final long curLex = lexNorm(iterate); + final long curLex = lexNorm(iterate, n); Assert.assertTrue(curLex > lastLex); lastLex = curLex; length++; @@ -431,12 +432,13 @@ public class CombinatoricsUtilsTest { * For example [3,2,1] returns 123. * * @param iterate input array + * @param n size of universe * @return lexicographic norm */ - private long lexNorm(int[] iterate) { + private long lexNorm(int[] iterate, int n) { long ret = 0; for (int i = iterate.length - 1; i >= 0; i--) { - ret += iterate[i] * ArithmeticUtils.pow(10l, (long) i); + ret += iterate[i] * ArithmeticUtils.pow(n, (long) i); } return ret; }