mirror of https://github.com/apache/jmeter.git
Bug 61071 : Bug 61071 - Median calculated incorrectly
Add Test contributed by Aleksei Balan within PR 295
Add another test showing a bug on getPercentPoint()
Bugzilla Id: 61071
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1794137 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: 903f061885
This commit is contained in:
parent
4f09bac234
commit
7c183d1ebc
|
@ -22,7 +22,10 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestStatCalculator {
|
||||
|
@ -37,19 +40,34 @@ public class TestStatCalculator {
|
|||
|
||||
@Test
|
||||
public void testPercentagePoint() throws Exception {
|
||||
calc.addValue(10);
|
||||
calc.addValue(9);
|
||||
calc.addValue(5);
|
||||
calc.addValue(6);
|
||||
calc.addValue(1);
|
||||
calc.addValue(3);
|
||||
calc.addValue(8);
|
||||
calc.addValue(2);
|
||||
calc.addValue(7);
|
||||
calc.addValue(4);
|
||||
long values[] = new long[] {
|
||||
10L,9L,5L,6L,1L,3L,8L,2L,7L,4L
|
||||
};
|
||||
for (long l : values) {
|
||||
calc.addValue(l);
|
||||
}
|
||||
assertEquals(10, calc.getCount());
|
||||
assertEquals(9, calc.getPercentPoint(0.8999999).intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
// Disabled due to in progress Bug 61071
|
||||
public void testPercentagePointBug() throws Exception {
|
||||
long values[] = new long[] {
|
||||
10L,9L,5L,6L,1L,3L,8L,2L,7L,4L
|
||||
};
|
||||
DescriptiveStatistics statistics = new DescriptiveStatistics();
|
||||
for (long l : values) {
|
||||
calc.addValue(l);
|
||||
statistics.addValue(l);
|
||||
}
|
||||
assertEquals(9, calc.getPercentPoint(0.8999999).intValue());
|
||||
//
|
||||
assertEquals(Math.round(statistics.getPercentile(90)),
|
||||
calc.getPercentPoint(0.9).intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculation() {
|
||||
assertEquals(Long.MIN_VALUE, calc.getMax().longValue());
|
||||
|
@ -70,6 +88,23 @@ public class TestStatCalculator {
|
|||
assertEquals(3, calc.getMin().intValue());
|
||||
assertEquals(15, calc.getMedian().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
// Disabled due to in progress Bug 61071
|
||||
public void testMedianBug61071() {
|
||||
long[] values = new long[] {
|
||||
10L, 20L, 30L, 40L, 50L, 60L, 80L, 90L
|
||||
};
|
||||
DescriptiveStatistics statistics = new DescriptiveStatistics();
|
||||
|
||||
for (long l : values) {
|
||||
calc.addValue(l);
|
||||
statistics.addValue(l);
|
||||
}
|
||||
assertEquals((int) statistics.getPercentile(50), calc.getMedian().intValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLong(){
|
||||
calc.addValue(0L);
|
||||
|
|
Loading…
Reference in New Issue