Skip to content

Commit 06838db

Browse files
tests/unit/test_xaprintf.c: Fix test by using streq() instead of strcmp(3)
Fixes: 423fd65 (2025-06-03; "lib/string/sprintf/, tests/unit/: Transform x[v]asprintf() into x[v]aprintf()") Reported-by: Timo Gurr <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
1 parent 71ea499 commit 06838db

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tests/unit/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ test_typetraits_LDADD = \
132132
test_xaprintf_SOURCES = \
133133
../../lib/string/sprintf/aprintf.c \
134134
../../lib/string/sprintf/xaprintf.c \
135+
../../lib/string/strcmp/streq.c \
135136
test_xaprintf.c \
136137
$(NULL)
137138
test_xaprintf_CFLAGS = \

tests/unit/test_xaprintf.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// SPDX-License-Identifier: BSD-3-Clause
33

44

5+
#include "string/sprintf/xaprintf.h"
6+
57
#include <setjmp.h>
68
#include <stdarg.h>
79
#include <stddef.h>
@@ -14,7 +16,7 @@
1416
#include <stdint.h> // Required by <cmocka.h>
1517
#include <cmocka.h>
1618

17-
#include "string/sprintf/xaprintf.h"
19+
#include "string/strcmp/streq.h"
1820

1921

2022
#define smock() _Generic(mock(), uintmax_t: (intmax_t) mock())
@@ -76,15 +78,15 @@ test_xaprintf_exit(void **state)
7678
assert_unreachable();
7779
break;
7880
case EXIT_CALLED:
79-
assert_true(strcmp(p, "xaprintf_called"));
81+
assert_true(streq(p, "xaprintf_called"));
8082
p = "test_ok";
8183
break;
8284
default:
8385
assert_unreachable();
8486
break;
8587
}
8688

87-
assert_true(strcmp(p, "test_ok"));
89+
assert_true(streq(p, "test_ok"));
8890
}
8991

9092

0 commit comments

Comments
 (0)