mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-06 20:33:54 +00:00
attempt at incrementally refreshing the wind estimation cache instead of entirely removing interval's contents
This commit is contained in:
1 parent
3cd358b24a
commit
1565e12e43
3 files changed
+133
-26
No files matched your search
Executable
+45
@@ -0,0 +1,45 @@
|
||||
package com.sap.sailing.domain.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.util.impl.ArrayListNavigableSet;
|
||||
|
||||
public class ArrayListNavigableSetTest {
|
||||
@Test
|
||||
public void testReplacementInHashSet() {
|
||||
Set<Integer> hashSet = new HashSet<Integer>();
|
||||
testSet(hashSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplacementInArrayListNavigableSet() {
|
||||
Set<Integer> arrayListNavigableSet = new ArrayListNavigableSet<Integer>(new Comparator<Integer>() {
|
||||
@Override
|
||||
public int compare(Integer o1, Integer o2) {
|
||||
return o1.compareTo(o2);
|
||||
}
|
||||
});
|
||||
testSet(arrayListNavigableSet);
|
||||
}
|
||||
|
||||
private void testSet(Set<Integer> hashSet) {
|
||||
Integer i1 = new Integer(1);
|
||||
Integer i2 = new Integer(1);
|
||||
assertNotSame(i1, i2);
|
||||
assertEquals(i1, i2);
|
||||
hashSet.add(i1);
|
||||
boolean replaced = hashSet.add(i2);
|
||||
assertFalse(replaced); // because s1 and s2 are equal
|
||||
Integer integerFromSet = hashSet.iterator().next();
|
||||
assertSame(i1, integerFromSet); // supposedly not replaced
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user