More tests for array/pool

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-05-18 12:02:24 +02:00
parent ace42b6f46
commit 188d316e15
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package net.minestom.server.utils;
import net.minestom.server.utils.binary.BinaryBuffer;
import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.L_Result;
import static org.openjdk.jcstress.annotations.Expect.ACCEPTABLE;
@JCStressTest
@Outcome(id = "1", expect = ACCEPTABLE)
@Outcome(id = "2", expect = ACCEPTABLE)
@State
public class ObjectPoolTest {
private final ObjectPool<BinaryBuffer> pool = ObjectPool.BUFFER_POOL;
@Actor
public void actor1() {
var buffer = pool.get();
pool.add(buffer);
}
@Actor
public void actor2() {
var buffer = pool.get();
pool.add(buffer);
}
@Arbiter
public void arbiter(L_Result r) {
r.r1 = pool.count();
}
}

View File

@ -0,0 +1,29 @@
package net.minestom.server.utils.collection;
import org.openjdk.jcstress.annotations.*;
import org.openjdk.jcstress.infra.results.LL_Result;
import static org.openjdk.jcstress.annotations.Expect.ACCEPTABLE;
@JCStressTest
@Outcome(id = "1, 2", expect = ACCEPTABLE)
@State
public class ObjectArrayTest {
private final ObjectArray<Integer> array = ObjectArray.concurrent();
@Actor
public void actor1() {
array.set(255, 1);
}
@Actor
public void actor2() {
array.set(32_000, 2);
}
@Arbiter
public void arbiter(LL_Result r) {
r.r1 = array.get(255);
r.r2 = array.get(32_000);
}
}