Go to the documentation of this file.
15 #include "absl/strings/ascii.h"
22 #include "gtest/gtest.h"
23 #include "absl/base/macros.h"
24 #include "absl/base/port.h"
28 TEST(AsciiIsFoo, All) {
29 for (
int i = 0;
i < 256;
i++) {
30 if ((
i >=
'a' &&
i <=
'z') || (
i >=
'A' &&
i <=
'Z'))
35 for (
int i = 0;
i < 256;
i++) {
36 if ((
i >=
'0' &&
i <=
'9'))
41 for (
int i = 0;
i < 256;
i++) {
47 for (
int i = 0;
i < 256;
i++) {
48 if (
i !=
'\0' && strchr(
" \r\n\t\v\f",
i))
53 for (
int i = 0;
i < 256;
i++) {
54 if (
i >= 32 &&
i < 127)
59 for (
int i = 0;
i < 256;
i++) {
66 for (
int i = 0;
i < 256;
i++) {
67 if (
i ==
' ' ||
i ==
'\t')
72 for (
int i = 0;
i < 256;
i++) {
73 if (
i < 32 ||
i == 127)
78 for (
int i = 0;
i < 256;
i++) {
80 (
i >=
'a' &&
i <=
'f'))
85 for (
int i = 0;
i < 256;
i++) {
86 if (
i > 32 &&
i < 127)
91 for (
int i = 0;
i < 256;
i++) {
92 if (
i >=
'A' &&
i <=
'Z')
97 for (
int i = 0;
i < 256;
i++) {
98 if (
i >=
'a' &&
i <=
'z')
103 for (
int i = 0;
i < 128;
i++) {
106 for (
int i = 128;
i < 256;
i++) {
112 for (
int i = 0;
i < 256;
i++) {
113 signed char sc =
static_cast<signed char>(
static_cast<unsigned char>(
i));
132 TEST(AsciiIsFoo, SameAsIsFoo) {
135 const char* old_locale = setlocale(LC_CTYPE,
"C");
139 for (
int i = 0;
i < 256;
i++) {
161 TEST(AsciiToFoo, All) {
164 const char* old_locale = setlocale(LC_CTYPE,
"C");
168 for (
int i = 0;
i < 256;
i++) {
185 signed char sc =
static_cast<signed char>(
static_cast<unsigned char>(
i));
195 TEST(AsciiStrTo, Lower) {
196 const char buf[] =
"ABCDEF";
209 char mutable_buf[] =
"Mutable";
210 std::transform(mutable_buf, mutable_buf + strlen(mutable_buf),
215 TEST(AsciiStrTo, Upper) {
216 const char buf[] =
"abcdef";
225 char mutable_buf[] =
"Mutable";
226 std::transform(mutable_buf, mutable_buf + strlen(mutable_buf),
239 {
"\t \n\f\r\v\n\t \n\f\r\v\n"}));
252 str =
"\t \n\f\r\n\vfoo";
256 str =
"\t \n\f\r\n\vfoo foo\n ";
260 str =
"\t \n\f\r\v\n\t \n\f\r\v\n";
273 {
"\t \n\f\r\v\n\t \n\f\r\v\n"}));
286 str =
"foo\t \n\f\r\n\v";
290 str =
" \nfoo foo\t \n\f\r\n\v";
294 str =
"\t \n\f\r\v\n\t \n\f\r\v\n";
306 {
"\t \n\f\r\n\vfoo foo\t \n\f\r\n\v"}));
321 str =
"\t \n\f\r\n\vfoo\t \n\f\r\n\v";
325 str =
"\t \n\f\r\n\vfoo foo\t \n\f\r\n\v";
329 str =
"\t \n\f\r\v\n\t \n\f\r\v\n";
335 const char* inputs[] = {
"No extra space",
336 " Leading whitespace",
337 "Trailing whitespace ",
338 " Leading and trailing ",
339 " Whitespace \t in\v middle ",
340 "'Eeeeep! \n Newlines!\n",
343 "\n\t a\t\n\nb \t\n"};
345 const char* outputs[] = {
347 "Leading whitespace",
348 "Trailing whitespace",
349 "Leading and trailing",
350 "Whitespace in middle",
351 "'Eeeeep! Newlines!",
358 for (
int i = 0;
i < NUM_TESTS;
i++) {
ABSL_MUST_USE_RESULT absl::string_view StripAsciiWhitespace(absl::string_view str)
bool ascii_isblank(unsigned char c)
char ascii_tolower(unsigned char c)
void RemoveExtraAsciiWhitespace(std::string *str)
ABSL_MUST_USE_RESULT absl::string_view StripTrailingAsciiWhitespace(absl::string_view str)
bool ascii_iscntrl(unsigned char c)
bool ascii_isgraph(unsigned char c)
#define ABSL_ARRAYSIZE(array)
void AsciiStrToLower(std::string *s)
bool ascii_isspace(unsigned char c)
bool ascii_isalnum(unsigned char c)
bool ascii_isascii(unsigned char c)
void AsciiStrToUpper(std::string *s)
#define TEST(name, init_size,...)
bool ascii_isprint(unsigned char c)
ABSL_MUST_USE_RESULT absl::string_view StripLeadingAsciiWhitespace(absl::string_view str)
bool ascii_islower(unsigned char c)
bool ascii_isupper(unsigned char c)
bool ascii_isalpha(unsigned char c)
#define EXPECT_STREQ(s1, s2)
char ascii_toupper(unsigned char c)
bool ascii_ispunct(unsigned char c)
#define ASSERT_TRUE(condition)
#define EXPECT_TRUE(condition)
bool ascii_isxdigit(unsigned char c)
bool ascii_isdigit(unsigned char c)
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:34