This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-rng.git
commit c57635db14a2cd1931124c2de975486637e9d61c Author: Alex Herbert <aherb...@apache.org> AuthorDate: Wed Jul 31 23:22:15 2019 +0100 Add code coverage test for large FactorialLog cache size. --- .../commons/rng/sampling/distribution/InternalUtilsTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java index 86f41de..f91a7c4 100644 --- a/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java +++ b/commons-rng-sampling/src/test/java/org/apache/commons/rng/sampling/distribution/InternalUtilsTest.java @@ -62,6 +62,17 @@ public class InternalUtilsTest { } @Test + public void testFactorialLogCacheSizeAboveRepresentableFactorials() { + final int limit = MAX_REPRESENTABLE + 5; + FactorialLog factorialLog = FactorialLog.create().withCache(limit); + for (int n = MAX_REPRESENTABLE; n <= limit; n++) { + // Use Commons math to compute logGamma(1 + n); + double expected = Gamma.logGamma(1 + n); + Assert.assertEquals(expected, factorialLog.value(n), 1e-10); + } + } + + @Test public void testFactorialLogCacheExpansion() { // There is no way to determine if the cache values were reused but this test // exercises the method to ensure it does not error.