[libc-commits] [PATCH] D147873: [libc] Add a test condition for EOF in ctype

Shivam Gupta via Phabricator via libc-commits libc-commits at lists.llvm.org
Sun Apr 9 00:16:04 PDT 2023


xgupta updated this revision to Diff 511960.
xgupta added a comment.

Update < x256 to <= 255


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147873/new/

https://reviews.llvm.org/D147873

Files:
  libc/test/src/ctype/isalpha_test.cpp


Index: libc/test/src/ctype/isalpha_test.cpp
===================================================================
--- libc/test/src/ctype/isalpha_test.cpp
+++ libc/test/src/ctype/isalpha_test.cpp
@@ -6,17 +6,22 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <stdio.h>
+
 #include "src/ctype/isalpha.h"
 
 #include "test/UnitTest/Test.h"
 
 TEST(LlvmLibcIsAlpha, DefaultLocale) {
   // Loops through all characters, verifying that letters return a
-  // non-zero integer and everything else returns zero.
-  for (int ch = 0; ch < 255; ++ch) {
-    if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
+  // non-zero integer and everything else including EOF returns zero.
+  for (int ch = 0; ch <= 255; ++ch) {
+    if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')) {
       EXPECT_NE(__llvm_libc::isalpha(ch), 0);
-    else
+    } else if (ch == EOF) {
+      EXPECT_EQ(__llvm_libc::isalpha(ch), 0);
+    } else {
       EXPECT_EQ(__llvm_libc::isalpha(ch), 0);
+    }
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147873.511960.patch
Type: text/x-patch
Size: 1041 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230409/b13425df/attachment.bin>


More information about the libc-commits mailing list