You do not need any special tool. Just pure Java and some maths (or minimal search-over-the-internet-or-at-least-over-the-stackexchange skills).
Here is your demo.
You only need to rework it for your input and for Assertion mechanism of your unit-test framework.
public class TestNumbers {
final static int numberLength = 3;
public static void main(String[] args) {
int[] testArrayOk = new int[]{
123,
321,
111,
};
int[] testArrayWithNoUnique = new int[]{
123,
321,
123,
};
int[] testArrayWithWrongLength = new int[]{
123,
321,
12,
};
testAll(testArrayOk);
testAll(testArrayWithNoUnique);
testAll(testArrayWithWrongLength);
}
static void testAll(int[] inputArray){
testForDups(inputArray);
testForLength(inputArray);
}
static boolean testForDups(int[] inputArray){
Set<Integer> findDupsSet = new HashSet<Integer>();
for (int item : inputArray)
{
if (findDupsSet.contains(item)) {
System.out.println("Dup detected in array: " + Arrays.toString(inputArray));
return true;
}
findDupsSet.add(item);
}
return false;
}
static boolean testForLength(int[] inputArray){
for(int i: inputArray){
if(1 + (int)Math.log10(i) != numberLength){
System.out.println("Item of improper length detected in array: " + Arrays.toString(inputArray));
return true;
}
}
return false;
}
}
Output:
Dup detected in array: [123, 321, 123]
Item of improper length detected in array: [123, 321, 12]
Solutions are taken from: