use of org.lanternpowered.server.util.collect.array.concurrent.AtomicNibbleArray in project LanternServer by LanternPowered.
the class AtomicNibbleArrayTest method testPackedArrayConstructor.
@Test
public void testPackedArrayConstructor() {
byte[] valuesPacked = { B | A << 4, (byte) (C | D << 4), E };
byte[] values = { B, A, C, D, E };
AtomicNibbleArray array = new AtomicNibbleArray(values.length, valuesPacked, true);
assertEquals(array.length(), values.length);
assertArrayEquals(values, array.getArray());
assertArrayEquals(valuesPacked, array.getPackedArray());
for (int i = 0; i < values.length; i++) {
assertEquals(array.get(i), values[i]);
array.set(i, (byte) i);
assertEquals(array.get(i), i);
}
}
use of org.lanternpowered.server.util.collect.array.concurrent.AtomicNibbleArray in project LanternServer by LanternPowered.
the class AtomicNibbleArrayTest method testGetSet.
@Test
public void testGetSet() {
AtomicNibbleArray array = new AtomicNibbleArray(SIZE);
for (int i = 0; i < array.length(); i++) {
array.set(i, A);
assertEquals(array.get(i), A);
array.set(i, B);
assertEquals(array.get(i), B);
array.set(i, C);
assertEquals(array.get(i), C);
}
}
use of org.lanternpowered.server.util.collect.array.concurrent.AtomicNibbleArray in project LanternServer by LanternPowered.
the class AtomicNibbleArrayTest method testGetAndSet.
@Test
public void testGetAndSet() {
AtomicNibbleArray array = new AtomicNibbleArray(SIZE);
for (int i = 0; i < SIZE; i++) {
array.set(i, A);
assertEquals(A, array.getAndSet(i, B));
assertEquals(B, array.getAndSet(i, E));
assertEquals(E, array.getAndSet(i, A));
}
}
use of org.lanternpowered.server.util.collect.array.concurrent.AtomicNibbleArray in project LanternServer by LanternPowered.
the class AtomicNibbleArrayTest method testCompareAndSet.
@Test
public void testCompareAndSet() {
AtomicNibbleArray array = new AtomicNibbleArray(SIZE);
for (int i = 0; i < SIZE; i++) {
array.set(i, A);
assertTrue(array.compareAndSet(i, A, B));
assertTrue(array.compareAndSet(i, B, C));
assertEquals(C, array.get(i));
assertFalse(array.compareAndSet(i, D, E));
assertEquals(C, array.get(i));
assertTrue(array.compareAndSet(i, C, E));
assertEquals(E, array.get(i));
}
}
use of org.lanternpowered.server.util.collect.array.concurrent.AtomicNibbleArray in project LanternServer by LanternPowered.
the class AtomicNibbleArrayTest method testLazyGetSet.
@Test
public void testLazyGetSet() {
AtomicNibbleArray array = new AtomicNibbleArray(SIZE);
for (int i = 0; i < array.length(); i++) {
array.lazySet(i, A);
assertEquals(array.get(i), A);
array.lazySet(i, B);
assertEquals(array.get(i), B);
array.lazySet(i, C);
assertEquals(array.get(i), C);
}
}
Aggregations