Make error-status assertions authoritative
Replace standalone message assertions with a helper that checks the returned akerr status first, then validates message content only as secondary context. Drop ambiguous memcpy message checks where both NULL guards use the same format string.
This commit is contained in:
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "aksl_capture.h"
|
||||
|
||||
|
||||
static int test_malloc_writes_nonnull_pointer(void)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
@@ -23,15 +22,15 @@ static int test_malloc_writes_nonnull_pointer(void)
|
||||
|
||||
static int test_malloc_rejects_null_destination(void)
|
||||
{
|
||||
AKSL_CHECK_STATUS(aksl_malloc(32, NULL), AKERR_NULLPOINTER);
|
||||
AKSL_CHECK_MSG_CONTAINS("NULL");
|
||||
AKSL_CHECK_STATUS_MSG_CONTAINS(aksl_malloc(32, NULL),
|
||||
AKERR_NULLPOINTER, "NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_free_rejects_null_pointer(void)
|
||||
{
|
||||
AKSL_CHECK_STATUS(aksl_free(NULL), AKERR_NULLPOINTER);
|
||||
AKSL_CHECK_MSG_CONTAINS("NULL");
|
||||
AKSL_CHECK_STATUS_MSG_CONTAINS(aksl_free(NULL),
|
||||
AKERR_NULLPOINTER, "NULL");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -79,8 +78,8 @@ static int test_memset_zero_length_is_noop(void)
|
||||
|
||||
static int test_memset_rejects_null_buffer(void)
|
||||
{
|
||||
AKSL_CHECK_STATUS(aksl_memset(NULL, 0x00, 4), AKERR_NULLPOINTER);
|
||||
AKSL_CHECK_MSG_CONTAINS("s=");
|
||||
AKSL_CHECK_STATUS_MSG_CONTAINS(aksl_memset(NULL, 0x00, 4),
|
||||
AKERR_NULLPOINTER, "s=");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -113,8 +112,8 @@ static int test_memcpy_rejects_null_destination(void)
|
||||
{
|
||||
unsigned char src[1] = { 1 };
|
||||
|
||||
AKSL_CHECK_STATUS(aksl_memcpy(NULL, src, sizeof(src)), AKERR_NULLPOINTER);
|
||||
AKSL_CHECK_MSG_CONTAINS("d=");
|
||||
AKSL_CHECK_STATUS(aksl_memcpy(NULL, src, sizeof(src)),
|
||||
AKERR_NULLPOINTER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -122,8 +121,8 @@ static int test_memcpy_rejects_null_source(void)
|
||||
{
|
||||
unsigned char dst[1] = { 0 };
|
||||
|
||||
AKSL_CHECK_STATUS(aksl_memcpy(dst, NULL, sizeof(dst)), AKERR_NULLPOINTER);
|
||||
AKSL_CHECK_MSG_CONTAINS("s=");
|
||||
AKSL_CHECK_STATUS(aksl_memcpy(dst, NULL, sizeof(dst)),
|
||||
AKERR_NULLPOINTER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user