Add test for first element for a maxAge iterator.

This commit is contained in:
asofold 2014-03-23 19:01:27 +01:00
parent a4aad90c82
commit f0f4a7ec2c

View File

@ -224,4 +224,24 @@ public class TestLocationTrace {
}
}
@Test
public void testMaxAgeFirstElementAnyway() {
int size = 80;
double mergeDist = -0.1; // Never merge.
LocationTrace trace = new LocationTrace(size, mergeDist);
trace.addEntry(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);
final Iterator<TraceEntry> 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.");
}
}
}