public void test() { final AtomicIntChunks ic = new AtomicIntChunks(42); set(0, ic); check(ic); assertFalse(ic.compareAndSet(20, 20, 40)); assertEquals(21, ic.get(20)); assertTrue(ic.compareAndSet(20, 21, 40)); assertEquals(40, ic.get(20)); assertEquals(32, ic.fieldBits()); }
private static void check(final AtomicIntChunks lc) { for (int i = 0; i < lc.length(); i++) { assertEquals(i + 1, lc.get(i)); } }
private static void set(final int start, final AtomicIntChunks lc) { for (int i = start; i < lc.length(); i++) { lc.set(i, i + 1); } }