git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] test-ctype: check EOF
@ 2023-04-30 10:00 René Scharfe
  2023-05-01 15:23 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2023-04-30 10:00 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

The character classifiers are supposed to handle EOF, a negative integer
value.  It isn't part of any character class.  Extend the ctype tests to
cover it.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 t/helper/test-ctype.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/t/helper/test-ctype.c b/t/helper/test-ctype.c
index 71a1a5c9b0..039703ee72 100644
--- a/t/helper/test-ctype.c
+++ b/t/helper/test-ctype.c
@@ -2,8 +2,10 @@

 static int rc;

-static void report_error(const char *class, int ch)
+static void test(int ch, const char *class, int expect, int actual)
 {
+	if (actual == expect)
+		return;
 	printf("%s classifies char %d (0x%02x) wrongly\n", class, ch, ch);
 	rc = 1;
 }
@@ -24,9 +26,9 @@ static int is_in(const char *s, int ch)
 #define TEST_CLASS(t,s) {			\
 	int i;					\
 	for (i = 0; i < 256; i++) {		\
-		if (is_in(s, i) != t(i))	\
-			report_error(#t, i);	\
+		test(i, #t, is_in(s, i), t(i));	\
 	}					\
+	test(EOF, #t, 0, t(EOF));		\
 }

 #define DIGIT "0123456789"
--
2.40.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-01 19:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-30 10:00 [PATCH] test-ctype: check EOF René Scharfe
2023-05-01 15:23 ` Junio C Hamano
2023-05-01 19:51   ` René Scharfe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).