1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-07 06:42:56 +03:00

Allow more signed integer types in test function arguments

Now that the C code supports the full range of intmax_t, allow any size of
signed integer type in the .data file parser.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine
2022-12-04 15:57:49 +01:00
parent 872948cc72
commit 6f5082bf4d
4 changed files with 49 additions and 5 deletions

View File

@@ -31,6 +31,31 @@ exit:
}
/* END_CASE */
/* BEGIN_CASE */
void printf_long_max(const char *format, long value)
{
char *expected = NULL;
char *output = NULL;
/* "0x" plus 2 hex digits per byte */
const size_t n = sizeof(value) * 2;
/* We assume that long has no padding bits! */
ASSERT_ALLOC(expected, n + 1);
expected[0] = '7';
memset(expected + 1, 'f', sizeof(value) * 2 - 1);
ASSERT_ALLOC(output, n + 1);
TEST_EQUAL(n, mbedtls_snprintf(output, n + 1, format, value));
ASSERT_COMPARE(expected, n + 1, output, n + 1);
mbedtls_free(output);
output = NULL;
exit:
mbedtls_free(output);
mbedtls_free(expected);
}
/* END_CASE */
/* BEGIN_CASE */
void printf_char2(char *format, int arg1, int arg2, char *result)
{