From 678e63007c35d9c6eb0dd4d5c81556d78b327a24 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Thu, 20 Apr 2023 12:28:59 +0100 Subject: [PATCH] Remove test-case for all-zero Signed-off-by: Dave Rodgman --- tests/suites/test_suite_bignum_core.function | 24 ++++++------------- tests/suites/test_suite_bignum_core.misc.data | 3 --- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/tests/suites/test_suite_bignum_core.function b/tests/suites/test_suite_bignum_core.function index a832a5123..6f810ff72 100644 --- a/tests/suites/test_suite_bignum_core.function +++ b/tests/suites/test_suite_bignum_core.function @@ -319,27 +319,17 @@ void mpi_core_clz(int lz, int tz) } mbedtls_mpi_uint x; - size_t expected; - - // generate x with lz leading zeros and tz trailing zeros, all other bits set. - if (lz == -1) { - // special case: all zero - x = 0; - expected = sizeof(mbedtls_mpi_uint) * 8; + if ((lz + tz) > 0) { + // some zero bits + uint32_t s = (sizeof(mbedtls_mpi_uint) * 8 - lz - tz); + x = ((((mbedtls_mpi_uint) 1) << s) - 1) << tz; } else { - expected = lz; - if ((lz + tz) > 0) { - // some zero bits - uint32_t s = (sizeof(mbedtls_mpi_uint) * 8 - lz - tz); - x = ((((mbedtls_mpi_uint) 1) << s) - 1) << tz; - } else { - // all bits set - x = ~((mbedtls_mpi_uint) 0); - } + // all bits set + x = ~((mbedtls_mpi_uint) 0); } size_t n = mbedtls_mpi_core_clz(x); - TEST_EQUAL(n, expected); + TEST_EQUAL(n, lz); exit: ; } diff --git a/tests/suites/test_suite_bignum_core.misc.data b/tests/suites/test_suite_bignum_core.misc.data index c245b02d3..ba8602997 100644 --- a/tests/suites/test_suite_bignum_core.misc.data +++ b/tests/suites/test_suite_bignum_core.misc.data @@ -494,9 +494,6 @@ mpi_core_fill_random:42:0:-5:0:MBEDTLS_ERR_MPI_BAD_INPUT_DATA CLZ: 0 0: all ones mpi_core_clz:0:0 -CLZ: -1 -1: all zeros -mpi_core_clz:-1:-1 - CLZ: 1 0 mpi_core_clz:1:0