@Test public void testConstructors() { OpenShortDoubleHashMap map = new OpenShortDoubleHashMap(); int[] capacity = new int[1]; double[] minLoadFactor = new double[1]; double[] maxLoadFactor = new double[1]; map.getInternalFactors(capacity, minLoadFactor, maxLoadFactor); assertEquals(AbstractSet.defaultCapacity, capacity[0]); assertEquals(AbstractSet.defaultMaxLoadFactor, maxLoadFactor[0], 0.001); assertEquals(AbstractSet.defaultMinLoadFactor, minLoadFactor[0], 0.001); int prime = PrimeFinder.nextPrime(907); map = new OpenShortDoubleHashMap(prime); map.getInternalFactors(capacity, minLoadFactor, maxLoadFactor); assertEquals(prime, capacity[0]); assertEquals(AbstractSet.defaultMaxLoadFactor, maxLoadFactor[0], 0.001); assertEquals(AbstractSet.defaultMinLoadFactor, minLoadFactor[0], 0.001); map = new OpenShortDoubleHashMap(prime, 0.4, 0.8); map.getInternalFactors(capacity, minLoadFactor, maxLoadFactor); assertEquals(prime, capacity[0]); assertEquals(0.4, minLoadFactor[0], 0.001); assertEquals(0.8, maxLoadFactor[0], 0.001); }
@Test public void testEnsureCapacity() { OpenShortDoubleHashMap map = new OpenShortDoubleHashMap(); int prime = PrimeFinder.nextPrime(907); map.ensureCapacity(prime); int[] capacity = new int[1]; double[] minLoadFactor = new double[1]; double[] maxLoadFactor = new double[1]; map.getInternalFactors(capacity, minLoadFactor, maxLoadFactor); assertEquals(prime, capacity[0]); }