forked from airlift/airlift
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
stats/src/test/java/com/facebook/airlift/stats/TestDistribution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.facebook.airlift.stats; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
public class TestDistribution | ||
{ | ||
@Test | ||
public void testMerge() | ||
{ | ||
Distribution distribution1 = new Distribution(); | ||
Distribution distribution2 = new Distribution(); | ||
|
||
for (int i = 0; i < 10; i++) { | ||
distribution1.add(i); | ||
} | ||
|
||
for (int i = 10; i < 20; i++) { | ||
distribution2.add(i); | ||
} | ||
|
||
distribution1.merge(distribution2); | ||
|
||
assertEquals(distribution1.getP50(), 10); | ||
assertEquals(distribution1.getMin(), 0); | ||
assertEquals(distribution1.getMax(), 19); | ||
assertEquals(distribution1.getCount(), 20.0); | ||
} | ||
|
||
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Expected decayCounter to have alpha.*") | ||
public void testMergeWithIncompatibleAlphaFails() | ||
{ | ||
Distribution distribution1 = new Distribution(0.5); | ||
Distribution distribution2 = new Distribution(0.7); | ||
|
||
distribution1.merge(distribution2); | ||
} | ||
} |