Skip to content

Commit eb7a82c

Browse files
committed
Add unit tests for com.tagtraum.perf.gcviewer.math.DoubleData
These tests were written using Diffblue Cover
1 parent e8eeb30 commit eb7a82c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/test/java/com/tagtraum/perf/gcviewer/math/TestDoubleData.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* Date: Jan 30, 2002
1010
* Time: 5:53:55 PM
1111
* @author <a href="mailto:[email protected]">Hendrik Schreiber</a>
12+
*
1213
*/
1314
public class TestDoubleData {
1415

@@ -18,14 +19,27 @@ public void testSimpleAverage() throws Exception {
1819
assertEquals("Simple average", 1.5, DoubleData.average(x), 0.0);
1920
}
2021

22+
@Test
2123
public void testSimpleStandardDeviation() throws Exception {
2224
DoubleData doubleData = new DoubleData();
2325
doubleData.add(1);
2426
doubleData.add(1);
2527
doubleData.add(-1);
2628
doubleData.add(-1);
27-
2829
assertEquals("Simple std deviation", 1.1547005383792515, doubleData.standardDeviation(), 0.0000001);
2930
}
3031

32+
@Test
33+
public void testWeightedAverage() {
34+
double[] n = {4.0, 5.0, 6.0};
35+
int[] weight = {2, 3, 4};
36+
assertEquals(5.222, DoubleData.weightedAverage(n, weight), 0.001);
37+
}
38+
39+
@Test
40+
public void testWeightedAverageNaN() {
41+
double[] n = {Double.NaN};
42+
int[] weight = {6, -1, 0, 0};
43+
assertEquals(Double.NaN, DoubleData.weightedAverage(n, weight), 0.0);
44+
}
3145
}

0 commit comments

Comments
 (0)