Commit 4335b3f8 by Abseil Team Committed by Copybara-Service

Update argument order of `EXPECT_EQ` in `absl::StrJoin` documentation.

PiperOrigin-RevId: 571487219
Change-Id: I6fbb2ff19db2b6d77e55059004d65c8639eb7fca
parent f3ba72ee
...@@ -80,7 +80,7 @@ ABSL_NAMESPACE_BEGIN ...@@ -80,7 +80,7 @@ ABSL_NAMESPACE_BEGIN
// absl::StrJoin(v, ", ", [](std::string* out, absl::Duration dur) { // absl::StrJoin(v, ", ", [](std::string* out, absl::Duration dur) {
// absl::StrAppend(out, absl::FormatDuration(dur)); // absl::StrAppend(out, absl::FormatDuration(dur));
// }); // });
// EXPECT_EQ("1s, 10ms", s); // EXPECT_EQ(s, "1s, 10ms");
// //
// The following standard formatters are provided within this file: // The following standard formatters are provided within this file:
// //
...@@ -164,21 +164,21 @@ DereferenceFormatter() { ...@@ -164,21 +164,21 @@ DereferenceFormatter() {
// // of `absl::string_view` or even `const char*`. // // of `absl::string_view` or even `const char*`.
// std::vector<std::string> v = {"foo", "bar", "baz"}; // std::vector<std::string> v = {"foo", "bar", "baz"};
// std::string s = absl::StrJoin(v, "-"); // std::string s = absl::StrJoin(v, "-");
// EXPECT_EQ("foo-bar-baz", s); // EXPECT_EQ(s, "foo-bar-baz");
// //
// Example 2: // Example 2:
// // Joins the values in the given `std::initializer_list<>` specified using // // Joins the values in the given `std::initializer_list<>` specified using
// // brace initialization. This pattern also works with an initializer_list // // brace initialization. This pattern also works with an initializer_list
// // of ints or `absl::string_view` -- any `AlphaNum`-compatible type. // // of ints or `absl::string_view` -- any `AlphaNum`-compatible type.
// std::string s = absl::StrJoin({"foo", "bar", "baz"}, "-"); // std::string s = absl::StrJoin({"foo", "bar", "baz"}, "-");
// EXPECT_EQ("foo-bar-baz", s); // EXPECT_EQs, "foo-bar-baz");
// //
// Example 3: // Example 3:
// // Joins a collection of ints. This pattern also works with floats, // // Joins a collection of ints. This pattern also works with floats,
// // doubles, int64s -- any `StrCat()`-compatible type. // // doubles, int64s -- any `StrCat()`-compatible type.
// std::vector<int> v = {1, 2, 3, -4}; // std::vector<int> v = {1, 2, 3, -4};
// std::string s = absl::StrJoin(v, "-"); // std::string s = absl::StrJoin(v, "-");
// EXPECT_EQ("1-2-3--4", s); // EXPECT_EQ(s, "1-2-3--4");
// //
// Example 4: // Example 4:
// // Joins a collection of pointer-to-int. By default, pointers are // // Joins a collection of pointer-to-int. By default, pointers are
...@@ -189,7 +189,7 @@ DereferenceFormatter() { ...@@ -189,7 +189,7 @@ DereferenceFormatter() {
// int x = 1, y = 2, z = 3; // int x = 1, y = 2, z = 3;
// std::vector<int*> v = {&x, &y, &z}; // std::vector<int*> v = {&x, &y, &z};
// std::string s = absl::StrJoin(v, "-"); // std::string s = absl::StrJoin(v, "-");
// EXPECT_EQ("1-2-3", s); // EXPECT_EQ(s, "1-2-3");
// //
// Example 5: // Example 5:
// // Dereferencing of `std::unique_ptr<>` is also supported: // // Dereferencing of `std::unique_ptr<>` is also supported:
...@@ -198,7 +198,7 @@ DereferenceFormatter() { ...@@ -198,7 +198,7 @@ DereferenceFormatter() {
// v.emplace_back(new int(2)); // v.emplace_back(new int(2));
// v.emplace_back(new int(3)); // v.emplace_back(new int(3));
// std::string s = absl::StrJoin(v, "-"); // std::string s = absl::StrJoin(v, "-");
// EXPECT_EQ("1-2-3", s); // EXPECT_EQ(s, "1-2-3");
// //
// Example 6: // Example 6:
// // Joins a `std::map`, with each key-value pair separated by an equals // // Joins a `std::map`, with each key-value pair separated by an equals
...@@ -209,31 +209,31 @@ DereferenceFormatter() { ...@@ -209,31 +209,31 @@ DereferenceFormatter() {
// std::make_pair("b", 2), // std::make_pair("b", 2),
// std::make_pair("c", 3)}; // std::make_pair("c", 3)};
// std::string s = absl::StrJoin(m, ",", absl::PairFormatter("=")); // std::string s = absl::StrJoin(m, ",", absl::PairFormatter("="));
// EXPECT_EQ("a=1,b=2,c=3", s); // EXPECT_EQ(s, "a=1,b=2,c=3");
// //
// Example 7: // Example 7:
// // These examples show how `absl::StrJoin()` handles a few common edge // // These examples show how `absl::StrJoin()` handles a few common edge
// // cases: // // cases:
// std::vector<std::string> v_empty; // std::vector<std::string> v_empty;
// EXPECT_EQ("", absl::StrJoin(v_empty, "-")); // EXPECT_EQ(absl::StrJoin(v_empty, "-"), "");
// //
// std::vector<std::string> v_one_item = {"foo"}; // std::vector<std::string> v_one_item = {"foo"};
// EXPECT_EQ("foo", absl::StrJoin(v_one_item, "-")); // EXPECT_EQ(absl::StrJoin(v_one_item, "-"), "foo");
// //
// std::vector<std::string> v_empty_string = {""}; // std::vector<std::string> v_empty_string = {""};
// EXPECT_EQ("", absl::StrJoin(v_empty_string, "-")); // EXPECT_EQ(absl::StrJoin(v_empty_string, "-"), "");
// //
// std::vector<std::string> v_one_item_empty_string = {"a", ""}; // std::vector<std::string> v_one_item_empty_string = {"a", ""};
// EXPECT_EQ("a-", absl::StrJoin(v_one_item_empty_string, "-")); // EXPECT_EQ(absl::StrJoin(v_one_item_empty_string, "-"), "a-");
// //
// std::vector<std::string> v_two_empty_string = {"", ""}; // std::vector<std::string> v_two_empty_string = {"", ""};
// EXPECT_EQ("-", absl::StrJoin(v_two_empty_string, "-")); // EXPECT_EQ(absl::StrJoin(v_two_empty_string, "-"), "-");
// //
// Example 8: // Example 8:
// // Joins a `std::tuple<T...>` of heterogeneous types, converting each to // // Joins a `std::tuple<T...>` of heterogeneous types, converting each to
// // a std::string using the `absl::AlphaNum` class. // // a std::string using the `absl::AlphaNum` class.
// std::string s = absl::StrJoin(std::make_tuple(123, "abc", 0.456), "-"); // std::string s = absl::StrJoin(std::make_tuple(123, "abc", 0.456), "-");
// EXPECT_EQ("123-abc-0.456", s); // EXPECT_EQ(s, "123-abc-0.456");
template <typename Iterator, typename Formatter> template <typename Iterator, typename Formatter>
std::string StrJoin(Iterator start, Iterator end, absl::string_view sep, std::string StrJoin(Iterator start, Iterator end, absl::string_view sep,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment