// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, isblank, (int c)) {
- const unsigned char ch = static_cast<unsigned char>(c);
- return static_cast<int>(ch == ' ' || ch == '\t');
+ return static_cast<int>(c == ' ' || c == '\t');
}
} // namespace __llvm_libc
// TODO: Currently restricted to default locale.
// These should be extended using locale information.
LLVM_LIBC_FUNCTION(int, iscntrl, (int c)) {
- const unsigned char ch = static_cast<unsigned char>(c);
+ const unsigned ch = static_cast<unsigned>(c);
return static_cast<int>(ch < 0x20 || ch == 0x7f);
}
add_libc_testsuite(libc_ctype_unittests)
add_libc_unittest(
- isalnum
+ isalnum_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- isalpha
+ isalpha_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- isascii
+ isascii_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- isblank
+ isblank_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- iscntrl
+ iscntrl_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- isdigit
+ isdigit_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- isgraph
+ isgraph_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- islower
+ islower_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- isprint
+ isprint_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- ispunct
+ ispunct_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- isspace
+ isspace_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- isupper
+ isupper_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- isxdigit
+ isxdigit_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- toascii
+ toascii_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- tolower
+ tolower_test
SUITE
libc_ctype_unittests
SRCS
)
add_libc_unittest(
- toupper
+ toupper_test
SUITE
libc_ctype_unittests
SRCS
TEST(LlvmLibcIsAlNum, DefaultLocale) {
// Loops through all characters, verifying that numbers and letters
// return non-zero integer and everything else returns a zero.
- for (int c = 0; c < 255; ++c) {
+ for (int c = -255; c < 255; ++c) {
if (('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') ||
('0' <= c && c <= '9'))
EXPECT_NE(__llvm_libc::isalnum(c), 0);
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) {
+ for (int ch = -255; ch < 255; ++ch) {
if (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'))
EXPECT_NE(__llvm_libc::isalpha(ch), 0);
else
// Loops through all characters, verifying that ascii characters
// (which are all 7 bit unsigned integers)
// return a non-zero integer and everything else returns zero.
- for (int ch = 0; ch < 255; ++ch) {
- if (ch <= 0x7f)
+ for (int ch = -255; ch < 255; ++ch) {
+ if (0 <= ch && ch <= 0x7f)
EXPECT_NE(__llvm_libc::isascii(ch), 0);
else
EXPECT_EQ(__llvm_libc::isascii(ch), 0);
TEST(LlvmLibcIsBlank, DefaultLocale) {
// Loops through all characters, verifying that space and horizontal tab
// return a non-zero integer and everything else returns zero.
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if (ch == ' ' || ch == '\t')
EXPECT_NE(__llvm_libc::isblank(ch), 0);
else
TEST(LlvmLibcIsCntrl, DefaultLocale) {
// Loops through all characters, verifying that control characters
// return a non-zero integer, all others return zero.
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if ((0 <= ch && ch <= 0x1f /*US*/) || ch == 0x7f /*DEL*/)
EXPECT_NE(__llvm_libc::iscntrl(ch), 0);
else
TEST(LlvmLibcIsDigit, DefaultLocale) {
// Loops through all characters, verifying that numbers return a
// non-zero integer and everything else returns zero.
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if ('0' <= ch && ch <= '9')
EXPECT_NE(__llvm_libc::isdigit(ch), 0);
else
TEST(LlvmLibcIsGraph, DefaultLocale) {
// Loops through all characters, verifying that graphical characters
// return a non-zero integer, everything else returns zero.
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if ('!' <= ch && ch <= '~') // A-Z, a-z, 0-9, punctuation.
EXPECT_NE(__llvm_libc::isgraph(ch), 0);
else
TEST(LlvmLibcIsLower, DefaultLocale) {
// Loops through all characters, verifying that lowercase letters
// return a non-zero integer and everything else returns zero.
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if ('a' <= ch && ch <= 'z')
EXPECT_NE(__llvm_libc::islower(ch), 0);
else
#include "test/UnitTest/Test.h"
TEST(LlvmLibcIsPrint, DefaultLocale) {
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if (' ' <= ch && ch <= '~') // A-Z, a-z, 0-9, punctuation, space.
EXPECT_NE(__llvm_libc::isprint(ch), 0);
else
TEST(LlvmLibcIsPunct, DefaultLocale) {
// Loops through all characters, verifying that punctuation characters
// return a non-zero integer, and everything else returns zero.
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if (is_punctuation_character(ch))
EXPECT_NE(__llvm_libc::ispunct(ch), 0);
else
// 0x0b | vertical tab
// 0x0d | carriage return
// 0x20 | space
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if (ch == 0x20 || (0x09 <= ch && ch <= 0x0d))
EXPECT_NE(__llvm_libc::isspace(ch), 0);
else
TEST(LlvmLibcIsUpper, DefaultLocale) {
// Loops through all characters, verifying that uppercase letters
// return a non-zero integer and everything else returns zero.
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if ('A' <= ch && ch <= 'Z')
EXPECT_NE(__llvm_libc::isupper(ch), 0);
else
#include "test/UnitTest/Test.h"
TEST(LlvmLibcIsXDigit, DefaultLocale) {
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
if (('0' <= ch && ch <= '9') || ('a' <= ch && ch <= 'f') ||
('A' <= ch && ch <= 'F'))
EXPECT_NE(__llvm_libc::isxdigit(ch), 0);
// (which are all 7 bit unsigned integers)
// return themself, and that all other characters return themself
// mod 128 (which is equivalent to & 0x7f)
- for (int ch = 0; ch < 255; ++ch) {
- if (ch <= 0x7f)
+ for (int ch = -255; ch < 255; ++ch) {
+ if (0 <= ch && ch <= 0x7f)
EXPECT_EQ(__llvm_libc::toascii(ch), ch);
else
EXPECT_EQ(__llvm_libc::toascii(ch), ch & 0x7f);
#include "test/UnitTest/Test.h"
TEST(LlvmLibcToLower, DefaultLocale) {
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
// This follows pattern 'A' + 32 = 'a'.
if ('A' <= ch && ch <= 'Z')
EXPECT_EQ(__llvm_libc::tolower(ch), ch + 32);
#include "test/UnitTest/Test.h"
TEST(LlvmLibcToUpper, DefaultLocale) {
- for (int ch = 0; ch < 255; ++ch) {
+ for (int ch = -255; ch < 255; ++ch) {
// This follows pattern 'a' - 32 = 'A'.
if ('a' <= ch && ch <= 'z')
EXPECT_EQ(__llvm_libc::toupper(ch), ch - 32);