From 5c1173bc1b97b9da3b1d19e609c9822f3ac8471e Mon Sep 17 00:00:00 2001 From: Werner Lewis Date: Mon, 18 Jul 2022 17:22:58 +0100 Subject: [PATCH] Add test case generation for bignum add Signed-off-by: Werner Lewis --- tests/scripts/generate_bignum_tests.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/scripts/generate_bignum_tests.py b/tests/scripts/generate_bignum_tests.py index 36d0d22904..e8db99d091 100755 --- a/tests/scripts/generate_bignum_tests.py +++ b/tests/scripts/generate_bignum_tests.py @@ -204,6 +204,27 @@ class BignumCmpAbs(BignumCmp): super().__init__(val_l.strip("-"), val_r.strip("-")) +class BignumAdd(BignumOperation): + """Target for bignum addition test cases.""" + count = 0 + func = "mbedtls_mpi_add_mpi" + title = "MPI add" + input_cases = list(itertools.combinations( + [ + "1c67967269c6", "9cde3", + "-1c67967269c6", "-9cde3", + ], 2 + )) + + def __init__(self, val_l, val_r): + super().__init__(val_l, val_r) + self.symb = "+" + + @property + def result(self): + return quote_str(hex(self.int_l + self.int_r).replace("0x", "", 1)) + + class TestGenerator: """Generate test data."""