24 #include "gmock/gmock.h" 25 #include "gtest/gtest.h" 30 TEST(Strip, ConsumePrefixOneChar) {
33 EXPECT_EQ(input,
"bc");
36 EXPECT_EQ(input,
"bc");
39 EXPECT_EQ(input,
"c");
51 EXPECT_EQ(input,
"abcdef");
54 EXPECT_EQ(input,
"abcdef");
57 EXPECT_EQ(input,
"abcdef");
60 EXPECT_EQ(input,
"abcdef");
67 EXPECT_EQ(input,
"f");
73 EXPECT_EQ(input,
"abcdef");
76 EXPECT_EQ(input,
"abcdef");
79 EXPECT_EQ(input,
"abc");
83 EXPECT_EQ(input,
"abcdef");
86 EXPECT_EQ(input,
"abcde");
117 const char* inputs[] = {
119 " Leading whitespace",
120 "Trailing whitespace ",
121 " Leading and trailing ",
122 " Whitespace \t in\v middle ",
123 "'Eeeeep! \n Newlines!\n",
126 const char* outputs[] = {
128 "Leading whitespace",
129 "Trailing whitespace",
130 "Leading and trailing",
131 "Whitespace in middle",
132 "'Eeeeep! Newlines!",
137 for (
int i = 0;
i < NUM_TESTS;
i++) {
138 std::string s(inputs[
i]);
140 EXPECT_STREQ(outputs[
i], s.c_str());
146 std::string zero_string =
"";
147 assert(zero_string.empty());
149 EXPECT_EQ(zero_string.size(), 0);
150 EXPECT_TRUE(zero_string.empty());
154 std::string test =
"foo ";
156 EXPECT_EQ(test,
"foo");
168 EXPECT_EQ(test,
" abc");
174 orig =
"\t \n\f\r\v\n\t \n\f\r\v\n";
179 std::string test2 =
"\t \f\r\n\vfoo \t\f\r\v\n";
181 EXPECT_EQ(test2,
"foo");
182 std::string test3 =
"bar";
184 EXPECT_EQ(test3,
"bar");
185 std::string test4 =
"\t \f\r\n\vfoo";
187 EXPECT_EQ(test4,
"foo");
188 std::string test5 =
"foo \t\f\r\v\n";
190 EXPECT_EQ(test5,
"foo");
193 EXPECT_EQ(test6,
"foo");
195 EXPECT_EQ(test6,
"foo");
ABSL_MUST_USE_RESULT absl::string_view StripPrefix(absl::string_view str, absl::string_view prefix)
void RemoveExtraAsciiWhitespace(std::string *str)
bool ConsumePrefix(absl::string_view *str, absl::string_view expected)
ABSL_MUST_USE_RESULT absl::string_view StripAsciiWhitespace(absl::string_view str)
ABSL_MUST_USE_RESULT absl::string_view StripSuffix(absl::string_view str, absl::string_view suffix)
ABSL_MUST_USE_RESULT absl::string_view StripLeadingAsciiWhitespace(absl::string_view str)
TEST(Symbolize, Unimplemented)
bool ConsumeSuffix(absl::string_view *str, absl::string_view expected)
ABSL_MUST_USE_RESULT absl::string_view StripTrailingAsciiWhitespace(absl::string_view str)