@Test public void verifyAperiodicTemplates() throws Exception { final String[] templates = RandomnessUtils.aperiodicTemplates(length); Arrays.sort(templates); Arrays.sort(expectedAperiodicBits); assertArrayEquals(expectedAperiodicBits, templates); }
@Test public void verifyAperiodicValues() throws Exception { final int[] aperiodicValues = RandomnessUtils.aperiodicValues(length); Arrays.sort(aperiodicValues); final int[] expectedInts = toInts(expectedAperiodicBits); Arrays.sort(expectedInts); assertArrayEquals(expectedInts, aperiodicValues); }
@Test public void verifyPeriodicValues() throws Exception { final int[] periodicValues = RandomnessUtils.periodicValues(length); Arrays.sort(periodicValues); final int[] expectedAperiodicValues = toInts(expectedAperiodicBits); Arrays.sort(expectedAperiodicValues); for (int i = 0, periodicPointer = 0, aperiodicPointer = 0; i < (1 << length) - 1; i++) { if (i == periodicValues[periodicPointer]) { periodicPointer++; } else { assertEquals(i, expectedAperiodicValues[aperiodicPointer++]); } } assertEquals((1 << length) - expectedAperiodicValues.length, periodicValues.length); }
@Test public void verifyPeriodicTemplates() throws Exception { final String[] periodicTemplates = RandomnessUtils.periodicTemplates(length); Arrays.sort(periodicTemplates); Arrays.sort(expectedAperiodicBits); for (int i = 0, periodicPointer = 0, aperiodicPointer = 0; i < (1 << length) - 1; i++) { if (i == Integer.valueOf(periodicTemplates[periodicPointer], 2).intValue()) { assertEquals(length, periodicTemplates[periodicPointer].length()); periodicPointer++; } else { final int expectedAperiodicValue = Integer.valueOf(expectedAperiodicBits[aperiodicPointer++], 2).intValue(); assertEquals(i, expectedAperiodicValue); } } assertEquals((1 << length) - expectedAperiodicBits.length, periodicTemplates.length); }