Thanks for IntRangeSet - just what I needed.
I've found a bug in IntRangeSet.normalize().
Please find attached:
- a junit test to demonstrate it; and
- a patch to fix it.
Suggestion: It would be good to have junit tests
included in the source kit (in a separate test dir).
Cheers,
Neil.
Looks like I can only attach one file, so I've pasted
the junit test here:...
package bak.pcj.set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import bak.pcj.IntIterator;
import bak.pcj.set.IntRangeSet;
import junit.framework.TestCase;
public class IntRangeSetTest extends TestCase {
private final Log log = LogFactory.getLog(getClass());
public static void main(String[] args) {
junit.textui.TestRunner.run(IntRangeSetTest.class);
}
public void testIntRangeSet() {
IntRangeSet s = new IntRangeSet();
s.addAll(2, 4);
s.addAll(6, 10);
s.addAll(6, 8);
log.info(toString(s));
assertEquals("2, 3, 4, 6, 7, 8, 9, 10",
toString(s));
}
public static String toString(IntRangeSet seqIdNos) {
StringBuilder buf = new StringBuilder();
for (IntIterator iter = seqIdNos.iterator();
iter.hasNext();) {
int seqIdNo = iter.next();
if (buf.length() > 0) buf.append(", ");
buf.append(seqIdNo);
}
return buf.toString();
}
}
Patch for bug in IntRangeSet.normalize()
Junit test demonstrating 2nd bug.
Logged In: YES
user_id=1533000
I've found another bug and added a 2nd test case to
demonstrate it. Junit test attached.
Sorry but I haven't fixed this one. I've switch to
java.util.BitSet instead.
Logged In: YES
user_id=43402
Originator: NO
Bug filed under #1961875. Please not that the suggested patch does not work.