/** testIsEmptyNull */ public void testIsEmptyNull() { assertTrue(pset.toString(), pset.isEmpty()); assertTrue(set.toString(), set.isEmpty()); pset.add(HStoreConstants.NULL_PARTITION_ID); set.add(HStoreConstants.NULL_PARTITION_ID); assertFalse(pset.toString(), pset.isEmpty()); assertTrue(pset.toString(), pset.contains(HStoreConstants.NULL_PARTITION_ID)); assertFalse(set.toString(), set.isEmpty()); assertTrue(set.toString(), set.contains(HStoreConstants.NULL_PARTITION_ID)); assertEquals(set.size(), pset.size()); pset.clear(); set.clear(); assertTrue(pset.toString(), pset.isEmpty()); assertTrue(set.toString(), set.isEmpty()); assertEquals(set.size(), pset.size()); }
/** testIterator */ public void testIterator() { assertTrue(pset.isEmpty()); int num_elements = rand.nextInt(NUM_PARTITIONS * 3); for (int i = 0; i < num_elements; i++) { int p = rand.nextInt(NUM_PARTITIONS); pset.add(p); set.add(p); } // FOR assertFalse(pset.isEmpty()); assertEquals(set.size(), pset.size()); int cnt = 0; for (Integer p : pset) { // System.err.println(cnt + " - " + p); assertNotNull(pset.toString(), p); assertTrue(p.toString(), set.contains(p)); cnt++; } assertEquals(set.size(), cnt); }
/** testIsEmpty */ public void testIsEmpty() { assertTrue(pset.toString(), pset.isEmpty()); assertTrue(set.toString(), set.isEmpty()); for (int p = 0; p < NUM_PARTITIONS; p++) { assertFalse(pset.toString(), pset.contains(p)); assertFalse(set.toString(), set.contains(p)); pset.add(p); set.add(p); assertFalse(pset.toString(), pset.isEmpty()); assertTrue(pset.toString(), pset.contains(p)); assertFalse(set.toString(), set.isEmpty()); assertTrue(set.toString(), set.contains(p)); assertEquals(set.size(), pset.size()); } // FOR pset.clear(); set.clear(); assertTrue(pset.toString(), pset.isEmpty()); assertTrue(set.toString(), set.isEmpty()); assertEquals(set.size(), pset.size()); }
/** testAddAll */ public void testAddAll() { int num_elements = rand.nextInt(NUM_PARTITIONS * 3); for (int i = 0; i < num_elements; i++) { int p = rand.nextInt(NUM_PARTITIONS); set.add(p); } // FOR pset.addAll(set); assertFalse(pset.isEmpty()); assertEquals(set.size(), pset.size()); PartitionSet pset0 = new PartitionSet(); PartitionSet pset1 = new PartitionSet(); pset0.addAll(set); pset1.addAll(pset); assertEquals(pset0.size(), pset1.size()); assertEquals(pset0, pset1); }