star-sp

Random number generators and distributions
git clone git://git.meso-star.fr/star-sp.git
Log | Files | Refs | README | LICENSE

commit a157c554fff35c1abbbfc7896a8fd59f7e5b1522
parent 838d9947876d318e31b4f6a8128a7cf3a6183950
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 20 Oct 2021 11:01:55 +0200

Fix the proxy creation with a KISS rng type

On proxy creation, ssp considered that the KISS rng type was invalid.
As a consequence, the creation failed and returned an error. This commit
fixes this issue.

Diffstat:
Msrc/ssp_rng_proxy.c | 2+-
Msrc/test_ssp_rng_proxy.c | 7+++++++
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/ssp_rng_proxy.c b/src/ssp_rng_proxy.c @@ -590,7 +590,7 @@ ssp_rng_proxy_create2 || !out_proxy || !args->sequence_size || !args->nbuckets - || (!args->type && !args->rng) + || (args->type == SSP_RNG_TYPE_NULL && !args->rng) || args->sequence_pitch < args->sequence_size || args->sequence_size < args->nbuckets) { res = RES_BAD_ARG; diff --git a/src/test_ssp_rng_proxy.c b/src/test_ssp_rng_proxy.c @@ -68,6 +68,9 @@ test_creation(void) CHK(ssp_rng_proxy_get_type(proxy, &type) == RES_OK); CHK(type == SSP_RNG_THREEFRY); CHK(ssp_rng_proxy_ref_put(proxy) == RES_OK); + + CHK(ssp_rng_proxy_create(NULL, SSP_RNG_KISS, 4, &proxy) == RES_OK); + CHK(ssp_rng_proxy_ref_put(proxy) == RES_OK); } static void @@ -120,6 +123,10 @@ test_creation2(void) args.nbuckets = 4; CHK(ssp_rng_proxy_create2(NULL, &args, &proxy) == RES_OK); CHK(ssp_rng_proxy_ref_put(proxy) == RES_OK); + + args.type = SSP_RNG_KISS; + CHK(ssp_rng_proxy_create2(NULL, &args, &proxy) == RES_OK); + CHK(ssp_rng_proxy_ref_put(proxy) == RES_OK); } static void