Fixed the problems. Should work now.
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@838 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -62,7 +62,9 @@ public class StatisticalRuleTest
|
|||||||
|
|
||||||
public static final double MEAN = 499.5;
|
public static final double MEAN = 499.5;
|
||||||
public static final double SIGMA = 288.6750;
|
public static final double SIGMA = 288.6750;
|
||||||
public static final int NUM_TESTS = 32;
|
public static final int NUM_TESTS = 512;
|
||||||
|
|
||||||
|
public static final double DELTA = 0.005;
|
||||||
|
|
||||||
public StatisticalRuleTest(String name)
|
public StatisticalRuleTest(String name)
|
||||||
{
|
{
|
||||||
@ -155,12 +157,21 @@ public class StatisticalRuleTest
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns the expected number of reports.
|
* This returns the expected number of reports.
|
||||||
|
*
|
||||||
|
* If the Minimum comes in at 521.569 then we expect
|
||||||
|
* 522, 523, ... 999 will pass.
|
||||||
*/
|
*/
|
||||||
public int expectedMinimum(double minimum) {
|
public int expectedMinimum(double minimum) {
|
||||||
int RC = 999 - ((int) Math.round(minimum - 0.5) + 1);
|
Double d = new Double( minimum );
|
||||||
if (RC >= 0) return RC; else return 0;
|
return 999 - d.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testExpectedMinimum() {
|
||||||
|
for (int i = 0; i < 999; i++) {
|
||||||
|
assertEquals("Integer Min", 999 - i, expectedMinimum( i * 1.0 ));
|
||||||
|
assertEquals("Double Min", 999 - i, expectedMinimum( (i * 1.0) + 0.5 ));
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* This returns a random value for Top Score.
|
* This returns a random value for Top Score.
|
||||||
*/
|
*/
|
||||||
@ -173,6 +184,8 @@ public class StatisticalRuleTest
|
|||||||
* which will return more than the minimum provided.
|
* which will return more than the minimum provided.
|
||||||
*/
|
*/
|
||||||
public int randomTopScore(double target) {
|
public int randomTopScore(double target) {
|
||||||
|
if (target < 0) return 0;
|
||||||
|
|
||||||
return random.nextInt( (new Double(target)).intValue() );
|
return random.nextInt( (new Double(target)).intValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public abstract class StatisticalRule extends AbstractRule {
|
|||||||
while (points.hasNext()) {
|
while (points.hasNext()) {
|
||||||
DataPoint point = (DataPoint) points.next();
|
DataPoint point = (DataPoint) points.next();
|
||||||
|
|
||||||
if (point.getScore() >= (minValue - DELTA)) {
|
if (point.getScore() > (minValue - DELTA)) {
|
||||||
RC.add(point);
|
RC.add(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user