New strConcat concatenates strings in O(n) time.

* Accepts std::string and char const*.
* Also accepts numbers, bools and chars.
* New ripple::toString function augments std::to_string to handle
  bools and chars.
This commit is contained in:
Tom Swirly
2014-04-27 11:16:12 -04:00
committed by Vinnie Falco
parent 3c5e4e440b
commit 96e8cddfc2
2 changed files with 116 additions and 5 deletions

View File

@@ -412,14 +412,41 @@ public:
"parseUrl: Mixed://domain/path path failed");
}
void testStringConcat ()
{
testcase ("stringConcat");
auto result = stringConcat({});
expect(result == "", result);
result = stringConcat({"hello, ", std::string("world.")});
expect(result == "hello, world.", result);
result = stringConcat({"hello, ", 23});
expect(result == "hello, 23", result);
result = stringConcat({"hello, ", true});
expect(result == "hello, true", result);
result = stringConcat({"hello, ", 'x'});
expect(result == "hello, x", result);
}
void testToString ()
{
testcase ("toString");
auto result = toString("hello");
expect(result == "hello", result);
}
void run ()
{
testParseUrl ();
testUnHex ();
testStringConcat ();
testToString ();
}
};
BEAST_DEFINE_TESTSUITE(StringUtilities,ripple_basics,ripple);
BEAST_DEFINE_TESTSUITE(StringUtilities, ripple_basics, ripple);
} // ripple