diff --git a/libc/test/src/ctype/isalpha_test.cpp b/libc/test/src/ctype/isalpha_test.cpp --- a/libc/test/src/ctype/isalpha_test.cpp +++ b/libc/test/src/ctype/isalpha_test.cpp @@ -6,17 +6,22 @@ // //===----------------------------------------------------------------------===// +#include + #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); + } } }