Skip to content

Commit

Permalink
Sonar fix: Use @ParameterizedTest
Browse files Browse the repository at this point in the history
  • Loading branch information
aherbert committed May 4, 2022
1 parent a137830 commit ee10ce3
Showing 1 changed file with 7 additions and 23 deletions.
Expand Up @@ -24,6 +24,8 @@
import org.apache.commons.rng.simple.RandomSource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

/**
* Test for the {@link GuideTableDiscreteSampler}.
Expand Down Expand Up @@ -126,31 +128,13 @@ void testPoissonSamples() {

/**
* Test sampling from a non-uniform distribution of probabilities (these sum to 1).
* The alpha used in the default (1.0) or a smaller or larger value than the default.
*/
@Test
void testNonUniformSamplesWithProbabilities() {
final double[] expected = {0.1, 0.2, 0.3, 0.1, 0.3};
checkSamples(expected, 1.0);
}

/**
* Test sampling from a non-uniform distribution of probabilities with an alpha smaller than
* the default.
*/
@Test
void testNonUniformSamplesWithProbabilitiesWithSmallAlpha() {
final double[] expected = {0.1, 0.2, 0.3, 0.1, 0.3};
checkSamples(expected, 0.1);
}

/**
* Test sampling from a non-uniform distribution of probabilities with an alpha larger than
* the default.
*/
@Test
void testNonUniformSamplesWithProbabilitiesWithLargeAlpha() {
@ParameterizedTest
@ValueSource(doubles = {1.0, 0.1, 10.0})
void testNonUniformSamplesWithProbabilities(double alpha) {
final double[] expected = {0.1, 0.2, 0.3, 0.1, 0.3};
checkSamples(expected, 10.0);
checkSamples(expected, alpha);
}

/**
Expand Down

0 comments on commit ee10ce3

Please sign in to comment.