Commit 959b97a2 authored by Sebastian Holtermann's avatar Sebastian Holtermann
Browse files

Tests: testStringAlgorithms: Add cmTrimWhitespace, cmEscapeQuotes, cmTokenize

Extend the testStringAlgorithms test with tests for `cmTrimWhitespace`,
`cmEscapeQuotes` and `cmTokenize`.
parent 7fbcc16d
......@@ -37,6 +37,28 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ [])
}
};
// ----------------------------------------------------------------------
// Test cmTrimWhitespace
{
std::string base = "base";
std::string spaces = " \f\f\n\n\r\r\t\t\v\v";
assert_string(cmTrimWhitespace(spaces + base), base,
"cmTrimWhitespace front");
assert_string(cmTrimWhitespace(base + spaces), base,
"cmTrimWhitespace back");
assert_string(cmTrimWhitespace(spaces + base + spaces), base,
"cmTrimWhitespace front and back");
}
// ----------------------------------------------------------------------
// Test cmEscapeQuotes
{
assert_string(cmEscapeQuotes("plain"), "plain", "cmEscapeQuotes plain");
std::string base = "\"base\"\"";
std::string result = "\\\"base\\\"\\\"";
assert_string(cmEscapeQuotes(base), result, "cmEscapeQuotes escaped");
}
// ----------------------------------------------------------------------
// Test cmJoin
{
......@@ -51,6 +73,21 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ [])
"cmJoin std::vector long sep");
}
// ----------------------------------------------------------------------
// Test cmTokenize
{
typedef std::vector<std::string> VT;
assert_ok(cmTokenize("", ";") == VT{ "" }, "cmTokenize empty");
assert_ok(cmTokenize(";", ";") == VT{ "" }, "cmTokenize sep");
assert_ok(cmTokenize("abc", ";") == VT{ "abc" }, "cmTokenize item");
assert_ok(cmTokenize("abc;", ";") == VT{ "abc" }, "cmTokenize item sep");
assert_ok(cmTokenize(";abc", ";") == VT{ "abc" }, "cmTokenize sep item");
assert_ok(cmTokenize("abc;;efg", ";") == VT{ "abc", "efg" },
"cmTokenize item sep sep item");
assert_ok(cmTokenize("a1;a2;a3;a4", ";") == VT{ "a1", "a2", "a3", "a4" },
"cmTokenize multiple items");
}
// ----------------------------------------------------------------------
// Test cmStrCat
{
......
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