use of fr.neatmonster.nocheatplus.checks.moving.location.tracking.LocationTrace in project NoCheatPlus by NoCheatPlus.
the class TestLocationTrace method testMaxAgeIterator.
@Test
public void testMaxAgeIterator() {
int size = 80;
LocationTrace trace = new LocationTrace(size, size, pool);
// Adding up to size elements.
for (int i = 0; i < size; i++) {
trace.addEntry(i, i, i, i, 0, 0);
}
for (int i = 0; i < size; i++) {
Iterator<ITraceEntry> it = trace.maxAgeIterator(i);
long got = it.next().getTime();
if (got != i) {
fail("Bad entry point for iterator (maxAge), expected " + i + ", got instead: " + got);
}
int n = 1;
while (it.hasNext()) {
it.next();
n++;
}
if (n != size - i) {
fail("Bad number of elements for iterator (maxAge), expected " + (size - i) + ", got instead: " + n);
}
}
}
use of fr.neatmonster.nocheatplus.checks.moving.location.tracking.LocationTrace in project NoCheatPlus by NoCheatPlus.
the class TestLocationTrace method testMaxAgeFirstElementAnyway.
@Test
public void testMaxAgeFirstElementAnyway() {
int size = 80;
LocationTrace trace = new LocationTrace(size, size, pool);
trace.addEntry(0, 0, 0, 0, 0, 0);
if (!trace.maxAgeIterator(1000).hasNext()) {
fail("Expect iterator (maxAge) to always contain the latest element.");
}
trace.addEntry(1, 0, 0, 0, 0, 0);
final Iterator<ITraceEntry> it = trace.maxAgeIterator(2);
if (!it.hasNext()) {
fail("Expect iterator (maxAge) to always contain the latest element.");
}
it.next();
if (it.hasNext()) {
fail("Expect iterator (maxAge) to have only the latest element for all out of range entries.");
}
}
Aggregations