Menu

#3 Patch for bug in IntRangeSet.normalize()

open
nobody
None
5
2006-06-02
2006-06-02
Neil Bacon
No

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();
}

}

Discussion

  • Neil Bacon

    Neil Bacon - 2006-06-02

    Patch for bug in IntRangeSet.normalize()

     
  • Neil Bacon

    Neil Bacon - 2006-06-02

    Junit test demonstrating 2nd bug.

     
  • Neil Bacon

    Neil Bacon - 2006-06-02

    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.

     
  • Søren Bak

    Søren Bak - 2008-05-11

    Logged In: YES
    user_id=43402
    Originator: NO

    Bug filed under #1961875. Please not that the suggested patch does not work.

     

Log in to post a comment.

MongoDB Logo MongoDB