Sequencer { public static int next() { int tick = counter.getAndIncrement(); return tick & 0xff; } private  Sequencer(); static int next();  }
@Test public void sequencerShouldReturnIntegerIncrementallyFrom0To255(){ int pre = Sequencer.next(); int cur; for (int i = 0; i < 10000; ++i){ cur = Sequencer.next(); Assert.assertTrue(cur >= 0); Assert.assertTrue(cur <= 255); if(pre == 255){ pre = 0; Assert.assertEquals(0, cur); }else { Assert.assertEquals(1, cur - pre); pre = cur; } } }