use of org.lanternpowered.server.util.collect.array.concurrent.AtomicByteArray in project LanternServer by LanternPowered.
the class AtomicByteArrayTest method testGetSet.
@Test
public void testGetSet() {
AtomicByteArray array = new AtomicByteArray(SIZE);
for (int i = 0; i < array.length(); i++) {
array.set(i, A);
assertEquals(A, array.get(i));
array.set(i, B);
assertEquals(B, array.get(i));
array.set(i, C);
assertEquals(C, array.get(i));
}
}
use of org.lanternpowered.server.util.collect.array.concurrent.AtomicByteArray in project LanternServer by LanternPowered.
the class AtomicByteArrayTest method testGetAndSet.
@Test
public void testGetAndSet() {
AtomicByteArray array = new AtomicByteArray(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.AtomicByteArray in project LanternServer by LanternPowered.
the class AtomicByteArrayTest method testArrayConstructor.
@Test
public void testArrayConstructor() {
byte[] values = { B, A, C, D, E };
AtomicByteArray array = new AtomicByteArray(values);
assertEquals(array.length(), values.length);
assertArrayEquals(values, array.getArray());
for (int i = 0; i < values.length; i++) {
assertEquals(values[i], array.get(i));
array.set(i, (byte) i);
assertEquals(i, array.get(i));
}
}
use of org.lanternpowered.server.util.collect.array.concurrent.AtomicByteArray in project LanternServer by LanternPowered.
the class AtomicByteArrayTest method testCompareAndSet.
@Test
public void testCompareAndSet() {
AtomicByteArray array = new AtomicByteArray(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.AtomicByteArray in project LanternServer by LanternPowered.
the class AtomicByteArrayTest method testLazyGetSet.
@Test
public void testLazyGetSet() {
AtomicByteArray array = new AtomicByteArray(SIZE);
for (int i = 0; i < array.length(); i++) {
array.lazySet(i, A);
assertEquals(A, array.get(i));
array.lazySet(i, B);
assertEquals(B, array.get(i));
array.lazySet(i, C);
assertEquals(C, array.get(i));
}
}
Aggregations