15 #include "absl/strings/str_replace.h"
21 #include "gtest/gtest.h"
22 #include "absl/strings/str_cat.h"
23 #include "absl/strings/str_split.h"
111 "Abc!", {{
"a",
"x"}, {
"ab",
"xy"}, {
"b",
"y"}, {
"bc",
"yz"}, {
"c",
"z"}});
117 {{
"a",
"x"}, {
"ab",
"xy"}, {
"b",
"y"}, {
"bc!",
"yz?"}, {
"c!",
"z;"}});
140 {
"the lazy",
"liquor"},
142 EXPECT_EQ(s,
"pack my box with five dozen liquor jugs");
146 std::map<const char *, const char *> replacements;
147 replacements[
"$who"] =
"Bob";
148 replacements[
"$count"] =
"5";
149 replacements[
"#Noun"] =
"Apples";
152 EXPECT_EQ(
"Bob bought 5 Apples. Thanks Bob!", s);
160 {
"#Noun",
"Apples"}}, &s);
162 EXPECT_EQ(
"Bob bought 5 Apples. Thanks Bob!", s);
167 std::map<absl::string_view, absl::string_view> replacements;
168 replacements[
"$who"] =
"Bob";
169 replacements[
"$count"] =
"5";
170 replacements[
"#Noun"] =
"Apples";
174 EXPECT_EQ(
"Bob bought 5 Apples. Thanks Bob!", s);
187 auto it = splitter.begin();
196 std::vector<std::pair<std::string, std::string>> replacements;
203 replacements.push_back({
"a",
"A"});
208 replacements.push_back({
"b",
"B"});
213 replacements.push_back({
"d",
"D"});
221 std::map<const char*, const char*> replacements;
222 replacements[
"aa"] =
"x";
223 replacements[
"a"] =
"X";
232 std::list<std::pair<absl::string_view, absl::string_view>> replacements = {
233 {
"a",
"x"}, {
"b",
"y"}, {
"c",
"z"}};
240 using X = std::tuple<absl::string_view, std::string, int>;
241 std::vector<X> replacements(3);
242 replacements[0] =
X{
"a",
"x", 1};
243 replacements[1] =
X{
"b",
"y", 0};
244 replacements[2] =
X{
"c",
"z", -1};
251 std::vector<Cont> replacements(3);
252 replacements[0] =
Cont{
"a:x"};
253 replacements[1] =
Cont{
"b:y"};
254 replacements[2] =
Cont{
"c:z"};
298 {{
"a",
"x"}, {
"ab",
"xy"}, {
"b",
"y"}, {
"bc",
"yz"}, {
"c",
"z"}}, &s);
305 {{
"a",
"x"}, {
"ab",
"xy"}, {
"b",
"y"}, {
"bc!",
"yz?"}, {
"c!",
"z;"}}, &s);
326 s =
"the quick brown fox jumped over the lazy dogs";
336 {
"the lazy",
"liquor"},
340 EXPECT_EQ(s,
"pack my box with five dozen liquor jugs");