mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-18 09:51:17 +02:00
Add more tests for LocationTrace.
This commit is contained in:
parent
75da549f25
commit
79b0feb28e
@ -2,6 +2,7 @@ package fr.neatmonster.nocheatplus.test;
|
|||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -102,6 +103,13 @@ public class TestLocationTrace {
|
|||||||
fail("Wrong size, expect roughly half of " + (i + 1) + ", got instead: " + trace.size());
|
fail("Wrong size, expect roughly half of " + (i + 1) + ", got instead: " + trace.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Iterator<TraceEntry> it = trace.oldestIterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
if (it.next().lastDistSq > 1.0) {
|
||||||
|
fail("Spacing should be smaller than 1.0 (sq / actual).");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -132,9 +140,8 @@ public class TestLocationTrace {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIteratorSizeAndOrder() {
|
public void testIteratorSizeAndOrder() {
|
||||||
// Expected to fail.
|
|
||||||
int size = 80;
|
int size = 80;
|
||||||
double mergeDist = -0.1;
|
double mergeDist = -0.1; // Never merge.
|
||||||
LocationTrace trace = new LocationTrace(size, mergeDist);
|
LocationTrace trace = new LocationTrace(size, mergeDist);
|
||||||
// Adding up to size elements.
|
// Adding up to size elements.
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
@ -191,4 +198,30 @@ public class TestLocationTrace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMaxAgeIterator() {
|
||||||
|
int size = 80;
|
||||||
|
double mergeDist = -0.1; // Never merge.
|
||||||
|
LocationTrace trace = new LocationTrace(size, mergeDist);
|
||||||
|
// Adding up to size elements.
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
trace.addEntry(i, i, i, i);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
Iterator<TraceEntry> it = trace.maxAgeIterator(i);
|
||||||
|
long got = it.next().time;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user