Add some more tests for alpha_exponent_insertion
# SPDX-License-Identifier: LGPL-3.0-or-later
#
from unittest import mock
+from unittest.mock import MagicMock
from pynguin.utils.mutation_utils import alpha_exponent_insertion
@@ -13,5 +14,19 @@ def test_alpha_exponent_insertion():
insert = []
with mock.patch("pynguin.utils.randomness.next_float") as float_mock:
float_mock.return_value = 0.2
- alpha_exponent_insertion(insert, lambda: 5)
- assert insert == [5, 5, 5]
+ with mock.patch("pynguin.utils.randomness.next_int") as int_mock:
+ int_mock.side_effect = 1, 0
+ func = MagicMock()
+ func.side_effect = [0, 1, 2]
+ alpha_exponent_insertion(insert, func)
+ assert insert == [2, 0, 1]
+
+
+def test_alpha_exponent_insertion_none():
+ insert = []
+ with mock.patch("pynguin.utils.randomness.next_float") as float_mock:
+ float_mock.return_value = 0.2
+ func = MagicMock()
+ func.return_value = None
+ alpha_exponent_insertion(insert, func)
+ assert insert == []
