mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Bignum tests: add special cases to mod
Signed-off-by: Janos Follath <janos.follath@arm.com>
This commit is contained in:
@ -273,6 +273,15 @@ class ModOperationCommon(OperationCommon):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def input_cases_args(cls) -> Iterator[Tuple[Any, Any, Any]]:
|
||||||
|
if cls.arity == 1:
|
||||||
|
yield from ((n, a, "0") for a, n in cls.input_cases)
|
||||||
|
elif cls.arity == 2:
|
||||||
|
yield from ((n, a, b) for a, b, n in cls.input_cases)
|
||||||
|
else:
|
||||||
|
raise ValueError("Unsupported number of operands!")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate_function_tests(cls) -> Iterator[test_case.TestCase]:
|
def generate_function_tests(cls) -> Iterator[test_case.TestCase]:
|
||||||
if cls.input_style not in cls.input_styles:
|
if cls.input_style not in cls.input_styles:
|
||||||
@ -284,14 +293,18 @@ class ModOperationCommon(OperationCommon):
|
|||||||
for n in cls.moduli
|
for n in cls.moduli
|
||||||
for a, b in cls.get_value_pairs()
|
for a, b in cls.get_value_pairs()
|
||||||
for bil in cls.limb_sizes)
|
for bil in cls.limb_sizes)
|
||||||
|
special_cases = (cls(*args, bits_in_limb=bil)
|
||||||
|
for args in cls.input_cases_args()
|
||||||
|
for bil in cls.limb_sizes)
|
||||||
else:
|
else:
|
||||||
test_objects = (cls(n, a, b)
|
test_objects = (cls(n, a, b)
|
||||||
for n in cls.moduli
|
for n in cls.moduli
|
||||||
for a, b in cls.get_value_pairs())
|
for a, b in cls.get_value_pairs())
|
||||||
|
special_cases = (cls(*args) for args in cls.input_cases_args())
|
||||||
yield from (valid_test_object.create_test_case()
|
yield from (valid_test_object.create_test_case()
|
||||||
for valid_test_object in filter(
|
for valid_test_object in filter(
|
||||||
lambda test_object: test_object.is_valid,
|
lambda test_object: test_object.is_valid,
|
||||||
test_objects
|
chain(test_objects, special_cases)
|
||||||
))
|
))
|
||||||
|
|
||||||
# BEGIN MERGE SLOT 1
|
# BEGIN MERGE SLOT 1
|
||||||
|
Reference in New Issue
Block a user