#1082 Intersections of ranges are calculated wrong.

closed-works-for-me
nobody
General (896)
5
2012-06-11
2012-03-09
No

During excercises in a course in testing and veriication I discovered that intersections of ranges are checked wrongly in JFreeChart.
This working set, we are working with can be found at http://ge.tt/6FORJmE/v/0?c
I browsed your current trunk code online, and asserted that
- The unit tests are still the same (trunk/tests/org/jfree/data/junit/RangeTests.java)
- The implementation is still the same (trunk/source/org/jfree/data/Range.java)
I also checked out the current code, and tried to run the unittest

In org/jfree/data/Range.java, the implementation of the "intersects" function is currently:

public boolean intersects(double b0, double b1) {
if (b0 <= this.lower) {
return (b1 > this.lower);
}
else {
return (b0 < this.upper && b1 >= b0);
}
}

But should rather be

public boolean intersects(double b0, double b1) {
return (b0 <= b1 && this.lower < b1 && b0 < this.upper);
}

I made this implementation according to the unit tests in trunk/tests/org/jfree/data/junit/RangeTests.java, as well as some additional ones in src/org/jfree/data/RangeTests.java in the aforementioned working set.

Discussion

  • Addition:
    The line "I also checked out the current code, and tried to run the unittest" should read "I also checked out the current code, and tried to run the unit test here to be sure, but was unable to."

     
  • Martin Höller
    Martin Höller
    2012-03-12

    Thanks for the report. I'll have a look at it soon.
    What was your problem with the unit tests? They should run fine with a locale of "C".

     
  • I'm not usually programming Java, and I'm not sure I opened the checked out code the right way, and I have no idea of what you mean by 'a locale of "C"'.

     
  • Martin Höller
    Martin Höller
    2012-06-11

    • status: open --> closed-works-for-me
     
  • Martin Höller
    Martin Höller
    2012-06-11

    Hi again and sorry for the delay.

    Just had a look at your modified method and the additional tests. I can't see any problem with the existing implementation (and neither with your implementation). All tests run fine, the test coverage should be 100% and the tests look ok to me.

    If you still feel the current implementation is broken please provide a failing unit test.

    Thanks,
    - martin