29 std::vector<std::string> vs = {
"foo",
"bar",
"qux"};
30 std::vector<int> vi = {1, -89, 673, 0};
31 std::array ac = {
"blabla",
"xyz",
"4567"};
34 const char* sep2 =
", ";
35 std::string sep3 =
"<-->";
38 auto check = [](
const auto& range,
const auto& sep, std::string_view expected) {
39 std::string result1 =
join(range, sep);
40 CHECK(result1 == expected);
42 std::ostringstream ss;
43 ss <<
join(range, sep);
44 std::string result2 = ss.str();
45 CHECK(result2 == expected);
48 check(vs, sep1,
"foo-bar-qux");
49 check(vs, sep2,
"foo, bar, qux");
50 check(vs, sep3,
"foo<-->bar<-->qux");
51 check(vs, sep4,
"foo123bar123qux");
53 check(vi, sep1,
"1--89-673-0");
54 check(vi, sep2,
"1, -89, 673, 0");
55 check(vi, sep3,
"1<-->-89<-->673<-->0");
56 check(vi, sep4,
"1123-891236731230");
58 check(ac, sep1,
"blabla-xyz-4567");
59 check(ac, sep2,
"blabla, xyz, 4567");
60 check(ac, sep3,
"blabla<-->xyz<-->4567");
61 check(ac, sep4,
"blabla123xyz1234567");
63 auto quote = [](
auto& s) {
return strCat(
'\'', s,
'\''); };