Switch to using TEST_LE_S() and TEST_LE_U() in tests
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
diff --git a/tests/suites/test_suite_mpi.function b/tests/suites/test_suite_mpi.function
index 9567e5e..e4fca45 100644
--- a/tests/suites/test_suite_mpi.function
+++ b/tests/suites/test_suite_mpi.function
@@ -239,23 +239,23 @@
if( iret != 0 )
TEST_ASSERT( oret == 0 );
- TEST_ASSERT( 0 <= nb_int );
+ TEST_LE_S( 0, nb_int );
size_t nb = nb_int;
unsigned char buf[1024];
- TEST_ASSERT( nb <= sizeof( buf ) );
+ TEST_LE_U( nb, sizeof( buf ) );
/* nx_32_int is the number of 32 bit limbs, if we have 64 bit limbs we need
* to halve the number of limbs to have the same size. */
size_t nx;
- TEST_ASSERT( 0 <= nx_32_int );
+ TEST_LE_S( 0, nx_32_int );
if( sizeof( mbedtls_mpi_uint ) == 8 )
nx = nx_32_int / 2 + nx_32_int % 2;
else
nx = nx_32_int;
mbedtls_mpi_uint X[sizeof( buf ) / sizeof( mbedtls_mpi_uint )];
- TEST_ASSERT( nx <= sizeof( X ) / sizeof( X[0] ) );
+ TEST_LE_U( nx, sizeof( X ) / sizeof( X[0] ) );
int ret = mbedtls_mpi_core_read_be( X, nx, input->x, input->len );
TEST_EQUAL( ret, iret );
@@ -296,23 +296,23 @@
if( iret != 0 )
TEST_ASSERT( oret == 0 );
- TEST_ASSERT( 0 <= nb_int );
+ TEST_LE_S( 0, nb_int );
size_t nb = nb_int;
unsigned char buf[1024];
- TEST_ASSERT( nb <= sizeof( buf ) );
+ TEST_LE_U( nb, sizeof( buf ) );
/* nx_32_int is the number of 32 bit limbs, if we have 64 bit limbs we need
* to halve the number of limbs to have the same size. */
size_t nx;
- TEST_ASSERT( 0 <= nx_32_int );
+ TEST_LE_S( 0, nx_32_int );
if( sizeof( mbedtls_mpi_uint ) == 8 )
nx = nx_32_int / 2 + nx_32_int % 2;
else
nx = nx_32_int;
mbedtls_mpi_uint X[sizeof( buf ) / sizeof( mbedtls_mpi_uint )];
- TEST_ASSERT( nx <= sizeof( X ) / sizeof( X[0] ) );
+ TEST_LE_U( nx, sizeof( X ) / sizeof( X[0] ) );
int ret = mbedtls_mpi_core_read_le( X, nx, input->x, input->len );
TEST_EQUAL( ret, iret );
@@ -380,23 +380,23 @@
if( iret != 0 )
TEST_ASSERT( oret == 0 );
- TEST_ASSERT( 0 <= nb_int );
+ TEST_LE_S( 0, nb_int );
size_t nb = nb_int;
unsigned char buf[1024];
- TEST_ASSERT( nb <= sizeof( buf ) );
+ TEST_LE_U( nb, sizeof( buf ) );
/* nx_32_int is the number of 32 bit limbs, if we have 64 bit limbs we need
* to halve the number of limbs to have the same size. */
size_t nx;
- TEST_ASSERT( 0 <= nx_32_int );
+ TEST_LE_S( 0, nx_32_int );
if( sizeof( mbedtls_mpi_uint ) == 8 )
nx = nx_32_int / 2 + nx_32_int % 2;
else
nx = nx_32_int;
mbedtls_mpi_uint X[sizeof( buf ) / sizeof( mbedtls_mpi_uint )];
- TEST_ASSERT( nx <= sizeof( X ) / sizeof( X[0] ) );
+ TEST_LE_U( nx, sizeof( X ) / sizeof( X[0] ) );
int endian;
if( iendian == MBEDTLS_MPI_MOD_EXT_REP_INVALID )
@@ -738,7 +738,7 @@
size_t len = CHARS_TO_LIMBS(
input_X->len > input_Y->len ? input_X->len : input_Y->len );
- TEST_ASSERT( len <= MAX_LEN );
+ TEST_LE_U( len, MAX_LEN );
TEST_ASSERT( mbedtls_mpi_core_read_be( X, len, input_X->x, input_X->len )
== 0 );
@@ -1753,8 +1753,8 @@
TEST_EQUAL( 1, X->s );
/* Test cases are such that A <= B, so #limbs should be <= */
- TEST_ASSERT( A.n <= B.n );
- TEST_ASSERT( X->n <= B.n );
+ TEST_LE_U( A.n, B.n );
+ TEST_LE_U( X->n, B.n );
/* Now let's get arrays of mbedtls_mpi_uints, rather than MPI structures */
@@ -1870,7 +1870,7 @@
mbedtls_mpi *X = ( sizeof(mbedtls_mpi_uint) == 4 ) ? &X4 : &X8;
/* The result shouldn't have more limbs than the longest input */
- TEST_ASSERT( X->n <= limbs );
+ TEST_LE_U( X->n, limbs );
/* Now let's get arrays of mbedtls_mpi_uints, rather than MPI structures */
@@ -1975,7 +1975,7 @@
size_t bytes = limbs * sizeof(mbedtls_mpi_uint);
/* The result shouldn't have more limbs than the longest input */
- TEST_ASSERT( X->n <= limbs );
+ TEST_LE_U( X->n, limbs );
/* Now let's get arrays of mbedtls_mpi_uints, rather than MPI structures */
@@ -2075,9 +2075,10 @@
int limbs_AN = ( sizeof(mbedtls_mpi_uint) == 4 ) ? limbs_AN4 : limbs_AN8;
int limbs_B = ( sizeof(mbedtls_mpi_uint) == 4 ) ? limbs_B4 : limbs_B8;
- TEST_ASSERT( (size_t)limbs_AN >= A.n && (size_t)limbs_AN >= X->n );
- TEST_ASSERT( (size_t)limbs_B >= B.n );
- TEST_ASSERT( limbs_B <= limbs_AN );
+ TEST_LE_U( A.n, (size_t)limbs_AN );
+ TEST_LE_U( X->n, (size_t)limbs_AN );
+ TEST_LE_U( B.n, (size_t)limbs_B );
+ TEST_LE_U( limbs_B, limbs_AN );
/* All of the inputs are +ve (or zero) */
TEST_EQUAL( 1, A.s );