4static std::string rValue()
14static std::ostream& operator<<(std::ostream& os,
const MyType& m)
16 os <<
"--|" << m.
c <<
"|--";
22 std::string str =
"abc";
23 std::string_view sr =
"xyz";
24 const char* literal =
"foo";
25 char buf[100]; buf[0] =
'q'; buf[1] =
'u'; buf[2] =
'x'; buf[3] =
'\0';
27 unsigned char uc = 222;
89 CHECK(
strCat(literal, buf, rValue()) ==
"fooquxbar");
92 CHECK(
strCat(rValue(), i, literal) ==
"bar123456foo");
96 CHECK(
strCat(str, sr, literal, buf, c, uc, m, i, rValue(),
spaces(2), hex_string<2>(255)) ==
97 "abcxyzfooqux-222-31123456bar ff");
98 CHECK(
strCat(rValue(), uc, buf, c,
spaces(2), str, i, hex_string<3>(9999), sr, literal, m) ==
99 "bar222qux- abc12345670fxyzfoo-31");
103template<
typename... Args>
104static void testAppend(
const std::string& expected, Args&& ...args)
107 strAppend(s1, std::forward<Args>(args)...);
108 CHECK(s1 == expected);
110 std::string s2 =
"abcdefghijklmnopqrstuvwxyz";
111 strAppend(s2, std::forward<Args>(args)...);
112 CHECK(s2 == (
"abcdefghijklmnopqrstuvwxyz" + expected));
117 std::string str =
"mno";
118 std::string_view sr =
"rst";
119 const char* literal =
"ijklmn";
120 char buf[100]; buf[0] =
'd'; buf[1] =
'e'; buf[2] =
'\0'; buf[3] =
'f';
122 unsigned u = 4294967295u;
129 testAppend(
"bar", rValue());
130 testAppend(
"mno", str);
131 testAppend(
"rst", sr);
132 testAppend(
"ijklmn", literal);
133 testAppend(
"de", buf);
135 testAppend(
"4294967295", u);
136 testAppend(
"-876", ll);
137 testAppend(
" ",
spaces(10));
138 testAppend(
"fffffffc94", hex_string<10>(ll));
141 std::string s =
"bla";
144 CHECK(s ==
"blamnorstijklmn de+4294967295-876bar");
154auto test1(
int i) {
return strCat(i); }
156auto test2(
const char* s) {
return strCat(s); }
157auto test3(std::string_view s) {
return strCat(s); }
158auto test4(
const std::string& s) {
return strCat(s); }
159auto test5() {
return strCat(
"bla"); }
160auto test6() {
return strCat(
'a'); }
161auto test7(
char i) {
return strCat(
'a', i,
"bla"); }
162auto test8(
int i,
unsigned u) {
return strCat(i, u); }
164auto testA1(
const std::string& s1,
const std::string& s2) {
return strCat(s1, s2); }
165auto testA2(
const std::string& s1,
const std::string& s2) {
return s1 + s2; }
std::string to_string(std::integral auto x)
strCatImpl::ConcatSpaces spaces(size_t n)
std::string strCat(Ts &&...ts)
void strAppend(std::string &result, Ts &&...ts)