assert.h

Single-file assertion library for C
git clone git://git.finwo.net/lib/assert.h
Log | Files | Refs | README

commit 5170c0f97f98f5795726c1c18e6abf89835c4e68
parent fa2bd0a2810775f7578e9ac41754ee22c64eb492
Author: Robin Bron <robin.bron@yourhosting.nl>
Date:   Thu, 12 Mar 2026 23:27:29 +0100

Remove compiler warning

Diffstat:
Minclude/test.h | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/test.h b/include/test.h @@ -55,6 +55,15 @@ #include <string.h> /// +/// Helper function for string comparison to avoid NULL warnings +/// +static inline int _string_equals(const char *a, const char *b) { + if (a == NULL && b == NULL) return 1; + if (a == NULL || b == NULL) return 0; + return strcmp(a, b) == 0; +} + +/// /// API /// --- /// @@ -89,8 +98,8 @@ /// <summary>ASSERT_STRING_EQUALS(expected, actual)</summary> /// /// Perform an equal string assertion -///<C -#define ASSERT_STRING_EQUALS(expected, actual) ASSERT((#actual), strcmp((expected),(actual)) == 0) +///< +#define ASSERT_STRING_EQUALS(expected, actual) ASSERT((#actual), _string_equals((expected),(actual))) ///> /// </details>