Use TEST_EQUAL instead of TEST_ASSERT

Signed-off-by: Jethro Beekman <jethro@fortanix.com>
This commit is contained in:
Jethro Beekman 2023-05-03 17:39:36 +02:00
parent 3477a672b9
commit 2593ec4bee

View file

@ -41,21 +41,21 @@ void mbedtls_pem_write_buffer_lengths()
int ret; int ret;
for (size_t l = 0; l <= sizeof(data); l++) { for (size_t l = 0; l <= sizeof(data); l++) {
ret = mbedtls_pem_write_buffer("\n", "\n", data, l, NULL, 0, &olen_needed); ret = mbedtls_pem_write_buffer("\n", "\n", data, l, NULL, 0, &olen_needed);
TEST_ASSERT(ret == MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL); TEST_EQUAL(ret, MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL);
/* Test that a bigger buffer still only requires `olen_needed` */ /* Test that a bigger buffer still only requires `olen_needed` */
ret = mbedtls_pem_write_buffer("\n", "\n", data, l, buf, sizeof(buf), &olen); ret = mbedtls_pem_write_buffer("\n", "\n", data, l, buf, sizeof(buf), &olen);
TEST_ASSERT(ret == 0); TEST_EQUAL(ret, 0);
TEST_ASSERT(olen_needed == olen); TEST_EQUAL(olen_needed, olen);
/* Test that a buffer of exactly `olen_needed` works */ /* Test that a buffer of exactly `olen_needed` works */
memset(buf, 1, sizeof(buf)); memset(buf, 1, sizeof(buf));
ret = mbedtls_pem_write_buffer("\n", "\n", data, l, buf, olen_needed, &olen); ret = mbedtls_pem_write_buffer("\n", "\n", data, l, buf, olen_needed, &olen);
TEST_ASSERT(ret == 0); TEST_EQUAL(ret, 0);
TEST_ASSERT(olen_needed == olen); TEST_EQUAL(olen_needed, olen);
/* Test the function didn't overflow the given buffer */ /* Test the function didn't overflow the given buffer */
for (size_t i = olen_needed; i < sizeof(buf); i++) { for (size_t i = olen_needed; i < sizeof(buf); i++) {
TEST_ASSERT(buf[i] == 1); TEST_EQUAL(buf[i], 1);
} }
} }
} }