From 0f575ae0ae90d393167c49014a9d9b93863b5ea6 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Sat, 9 Oct 2021 16:18:37 +0200 Subject: [PATCH] Feat: testing list random generator --- test/calculus/random/test_list_generator.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/calculus/random/test_list_generator.py b/test/calculus/random/test_list_generator.py index f4bf747..2960fcd 100644 --- a/test/calculus/random/test_list_generator.py +++ b/test/calculus/random/test_list_generator.py @@ -32,5 +32,24 @@ def test_generate_list_calculus_math(): def test_generate_list_conditions(): - random_list = mapytex.random.list(["a", "b"], ) + a, b = mapytex.random.list(["a", "b"], conditions=["a + b == 10"]) + assert a + b == 10 + a, b = mapytex.random.list(["a", "b"], conditions=["a * b > 0", "a + b == 10"]) + assert a + b == 10 + assert a * b > 0 + +def test_generate_list_conditions_math(): + import math + a, b = mapytex.random.list(["a", "b"], conditions=["gcd(a, b) == 3"]) + assert math.gcd(a, b) == 3 + +def test_generate_list_global_config(): + global_config = {"rejected": [0, 1, 2, 3]} + a, = mapytex.random.list(["a"], global_config=global_config) + assert a not in global_config["rejected"] + + global_config = {"min_max": (20, 30)} + a, = mapytex.random.list(["a"], global_config=global_config) + assert a >= 20 + assert a <= 30