20 #include "gtest/gtest.h" 30 EXPECT_EQ(
"123 0.2 0.1 foo true false x",
32 std::string(
"foo"),
true,
false,
'x'));
37 "-1234567890 3234567890 " 38 "-1234567890 3234567890 " 39 "-1234567890123456789 9234567890123456789",
41 "$0 $1 $2 $3 $4 $5 $6 $7",
42 static_cast<short>(-32767),
43 static_cast<unsigned short>(65535),
44 -1234567890, 3234567890U, -1234567890L, 3234567890UL,
45 -int64_t{1234567890123456789}, uint64_t{9234567890123456789u}));
48 EXPECT_EQ(
"0 1 f ffff0ffff 0123456789abcdef",
57 EXPECT_EQ(
"0 115 -1-0001 81985529216486895",
66 const int* int_p =
reinterpret_cast<const int*
>(0x12345);
72 volatile int vol = 237;
73 volatile int *
volatile volptr = &vol;
75 EXPECT_EQ(
"true", str);
78 const uint64_t* null_p =
nullptr;
80 EXPECT_EQ(
"NULL", str);
83 const char* char_p =
"print me";
85 EXPECT_EQ(
"print me", str);
88 strncpy(char_buf,
"print me too",
sizeof(char_buf));
90 EXPECT_EQ(
"print me too", str);
98 EXPECT_EQ(
"b, a, c, b",
absl::Substitute(
"$1, $0, $2, $1",
"a",
"b",
"c"));
110 EXPECT_EQ(
"a b c d e",
112 EXPECT_EQ(
"a b c d e f",
absl::Substitute(
"$0 $1 $2 $3 $4 $5",
"a",
"b",
"c",
114 EXPECT_EQ(
"a b c d e f g",
absl::Substitute(
"$0 $1 $2 $3 $4 $5 $6",
"a",
"b",
115 "c",
"d",
"e",
"f",
"g"));
116 EXPECT_EQ(
"a b c d e f g h",
119 EXPECT_EQ(
"a b c d e f g h i",
121 "e",
"f",
"g",
"h",
"i"));
122 EXPECT_EQ(
"a b c d e f g h i j",
124 "d",
"e",
"f",
"g",
"h",
"i",
"j"));
125 EXPECT_EQ(
"a b c d e f g h i j b0",
127 "d",
"e",
"f",
"g",
"h",
"i",
"j"));
129 const char* null_cstring =
nullptr;
134 std::string str =
"Hello";
136 EXPECT_EQ(
"Hello, world!", str);
144 EXPECT_EQ(
"a b", str);
147 EXPECT_EQ(
"a b c", str);
150 EXPECT_EQ(
"a b c d", str);
153 EXPECT_EQ(
"a b c d e", str);
157 EXPECT_EQ(
"a b c d e f", str);
161 EXPECT_EQ(
"a b c d e f g", str);
165 EXPECT_EQ(
"a b c d e f g h", str);
168 "d",
"e",
"f",
"g",
"h",
"i");
169 EXPECT_EQ(
"a b c d e f g h i", str);
172 "c",
"d",
"e",
"f",
"g",
"h",
"i",
"j");
173 EXPECT_EQ(
"a b c d e f g h i j", str);
176 TEST(SubstituteTest, VectorBoolRef) {
177 std::vector<bool>
v = {
true,
false};
179 EXPECT_EQ(
"true false true false",
182 std::string str =
"Logic be like: ";
184 EXPECT_EQ(
"Logic be like: true false true false", str);
187 #ifdef GTEST_HAS_DEATH_TEST 189 TEST(SubstituteDeathTest, SubstituteDeath) {
192 "Invalid strings::Substitute\\(\\) format std::string: asked for \"\\$2\", " 193 "but only 2 args were given.");
196 "Invalid strings::Substitute\\(\\) format std::string: \"-\\$z-\"");
199 "Invalid strings::Substitute\\(\\) format std::string: \"-\\$\"");
202 #endif // GTEST_HAS_DEATH_TEST
std::string StrCat(const AlphaNum &a, const AlphaNum &b)
void SubstituteAndAppend(std::string *output, absl::string_view format)
TEST(Symbolize, Unimplemented)
ABSL_MUST_USE_RESULT std::string Substitute(absl::string_view format)