mirror of
https://github.com/cuberite/polarssl.git
synced 2025-10-02 10:00:47 -04:00
Remove test-case for all-zero
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
880a6b34c2
commit
678e63007c
@ -319,27 +319,17 @@ void mpi_core_clz(int lz, int tz)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_mpi_uint x;
|
mbedtls_mpi_uint x;
|
||||||
size_t expected;
|
if ((lz + tz) > 0) {
|
||||||
|
// some zero bits
|
||||||
// generate x with lz leading zeros and tz trailing zeros, all other bits set.
|
uint32_t s = (sizeof(mbedtls_mpi_uint) * 8 - lz - tz);
|
||||||
if (lz == -1) {
|
x = ((((mbedtls_mpi_uint) 1) << s) - 1) << tz;
|
||||||
// special case: all zero
|
|
||||||
x = 0;
|
|
||||||
expected = sizeof(mbedtls_mpi_uint) * 8;
|
|
||||||
} else {
|
} else {
|
||||||
expected = lz;
|
// all bits set
|
||||||
if ((lz + tz) > 0) {
|
x = ~((mbedtls_mpi_uint) 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t n = mbedtls_mpi_core_clz(x);
|
size_t n = mbedtls_mpi_core_clz(x);
|
||||||
TEST_EQUAL(n, expected);
|
TEST_EQUAL(n, lz);
|
||||||
exit:
|
exit:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -494,9 +494,6 @@ mpi_core_fill_random:42:0:-5:0:MBEDTLS_ERR_MPI_BAD_INPUT_DATA
|
|||||||
CLZ: 0 0: all ones
|
CLZ: 0 0: all ones
|
||||||
mpi_core_clz:0:0
|
mpi_core_clz:0:0
|
||||||
|
|
||||||
CLZ: -1 -1: all zeros
|
|
||||||
mpi_core_clz:-1:-1
|
|
||||||
|
|
||||||
CLZ: 1 0
|
CLZ: 1 0
|
||||||
mpi_core_clz:1:0
|
mpi_core_clz:1:0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user