protected void setUp() throws Exception { // Cluster a bunch in the center int min = RANGE / 3; for (int i = 0; i < NUM_SAMPLES; i++) { int val = rand.nextInt(min) + min; h.put(val); fast_h.fastPut(val); } for (int i = 0; i < NUM_SAMPLES; i++) { int val = rand.nextInt(RANGE); h.put(val); fast_h.fastPut(val); } }
/** testSerialization */ public void testSerialization() throws Exception { String json = fast_h.toJSONString(); assertFalse(json.isEmpty()); FastIntHistogram clone = new FastIntHistogram(); JSONObject jsonObj = new JSONObject(json); clone.fromJSON(jsonObj, null); assertEquals(fast_h.fastSize(), clone.fastSize()); for (int i = 0, cnt = fast_h.fastSize(); i < cnt; i++) { assertEquals(fast_h.fastGet(i), clone.fastGet(i)); } // FOR }
/** testValues */ public void testValues() throws Exception { Collection<Integer> vals0 = h.values(); Collection<Integer> vals1 = fast_h.values(); assertEquals(vals0.size(), vals1.size()); assertTrue(vals0.containsAll(vals1)); }
public void testMaxCountValues() { Collection<Integer> vals0 = h.getMaxCountValues(); Collection<Integer> vals1 = fast_h.getMaxCountValues(); assertEquals(vals0.size(), vals1.size()); assertTrue(vals0.containsAll(vals1)); }
public void testMaxValue() { assertEquals(h.getMaxValue(), fast_h.getMaxValue()); }
/** testMaxCount */ public void testMaxCount() throws Exception { assertEquals(h.getMaxCount(), fast_h.getMaxCount()); }
/** testValueCount */ public void testValueCount() { assertEquals(h.getValueCount(), fast_h.getValueCount()); }