@Test public void testDuplicates() { SpatialKeyHashtableOld store = new SpatialKeyHashtableOld().init(); assertEquals(0, store.put(12, 21, 123)); assertEquals(1, store.size()); assertEquals("location should already exist", 123, store.put(12, 21, 321)); assertEquals(1, store.size()); }
@Test public void testAdd() { SpatialKeyHashtableOld store = new SpatialKeyHashtableOld().init(); assertEquals(0, store.put(12, 21, 123)); assertEquals(123, store.get(12, 21)); assertEquals(1, store.size()); assertEquals(0, store.put(12, 21.0001f, 321)); assertEquals(321, store.get(12, 21.0001f)); assertEquals(2, store.size()); }
private void writeAndCheck( SpatialKeyHashtableOld store, long indexPartOfGeoHash, int maxEntries) { for (int i = 1; i <= maxEntries; i++) { assertEquals( "write i:" + i, 0, store.put(indexPartOfGeoHash | i << 8, Integer.MAX_VALUE / i)); } for (int i = 1; i <= maxEntries; i++) { assertEquals("check i:" + i, Integer.MAX_VALUE / i, store.get(indexPartOfGeoHash | i << 8)); } }