/**
* Test for duplicates when generating a bunch of IDs.
*/
private static void helpTestDuplicates( int nGen ) {
UUID uuid = null;
Set uuids = new HashSet();
// Set duplicates = new HashSet();
// First test some fairly "regular" numbers...
for ( int j = 0; j < Math.min(nGen,63); j++ ) {
long v1 = 1L << j;
long v2 = (1L << j)/2;
uuid = new UUID(v1,v2);
assertTrue( "UUID '" + uuid + "' is a duplicate!", !uuids.contains(uuid) ); //$NON-NLS-1$ //$NON-NLS-2$
uuids.add(uuid);
}
// Then test some random numbers...
java.util.Random rng = new java.util.Random();
for ( int k = 0; k < nGen; k++ ) {
long v1 = rng.nextLong();
long v2 = rng.nextLong();
uuid = new UUID(v1,v2);
if ( uuids.contains(uuid) ) {
fail( "UUID '" + uuid + "' is a duplicate!" ); //$NON-NLS-1$ //$NON-NLS-2$
}
uuids.add(uuid);
}