Skip to content

Commit

Permalink
ns
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Dec 19, 2024
1 parent f463861 commit 215c942
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/junit-functional/org/jgroups/tests/AverageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,17 @@ public void testAverage() {

public void testAverage2() {
Average avg=new Average(16);
double expected_avg=IntStream.rangeClosed(5, 20).sum() / 16.0;
IntStream.rangeClosed(1,20).forEach(avg::add);
double expected_avg=IntStream.rangeClosed(1, 16).sum() / 16.0;
IntStream.rangeClosed(1,16).forEach(avg::add);
double actual_avg=avg.average();
assert Util.withinRange(actual_avg, expected_avg, DEVIATION) : String.format("actual: %.2f expected: %.2f\n", actual_avg, expected_avg);
}


public void testAverage3() {
Average avg=new Average(16);
IntStream.rangeClosed(1,10_000).forEach(avg::add); // values towards 10'000 will dominate
double expected_avg=10_000;
double actual_avg=avg.average();
assert Util.withinRange(actual_avg, expected_avg, DEVIATION) : String.format("actual: %.2f expected: %.2f\n", actual_avg, expected_avg);
}
Expand Down

0 comments on commit 215c942

Please sign in to comment.