Search in sources :

Example 1 with AtomicByteArray

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));
    }
}
Also used : AtomicByteArray(org.lanternpowered.server.util.collect.array.concurrent.AtomicByteArray) Test(org.junit.Test)

Example 2 with AtomicByteArray

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));
    }
}
Also used : AtomicByteArray(org.lanternpowered.server.util.collect.array.concurrent.AtomicByteArray) Test(org.junit.Test)

Example 3 with AtomicByteArray

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));
    }
}
Also used : AtomicByteArray(org.lanternpowered.server.util.collect.array.concurrent.AtomicByteArray) Test(org.junit.Test)

Example 4 with AtomicByteArray

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));
    }
}
Also used : AtomicByteArray(org.lanternpowered.server.util.collect.array.concurrent.AtomicByteArray) Test(org.junit.Test)

Example 5 with AtomicByteArray

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));
    }
}
Also used : AtomicByteArray(org.lanternpowered.server.util.collect.array.concurrent.AtomicByteArray) Test(org.junit.Test)

Aggregations

AtomicByteArray (org.lanternpowered.server.util.collect.array.concurrent.AtomicByteArray)6 Test (org.junit.Test)5 AtomicIntegerArray (java.util.concurrent.atomic.AtomicIntegerArray)1 AtomicNibbleArray (org.lanternpowered.server.util.collect.array.concurrent.AtomicNibbleArray)1 AtomicShortArray (org.lanternpowered.server.util.collect.array.concurrent.AtomicShortArray)1