diff options
author | Brad King <brad.king@kitware.com> | 2019-08-07 15:45:15 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-08-07 15:47:54 (GMT) |
commit | ddb1759b3e2b5c1b2c56734cd2ae0fa6dcf3a815 (patch) | |
tree | fa0e32d0fdb3cf0b328b3a4181956868ca355b31 /Tests | |
parent | 97b12c7922f75c169736f65a3d9549a3084167c0 (diff) | |
parent | 959b97a27f8816fb1db5c3a1d51cd994086a886b (diff) | |
download | CMake-ddb1759b3e2b5c1b2c56734cd2ae0fa6dcf3a815.zip CMake-ddb1759b3e2b5c1b2c56734cd2ae0fa6dcf3a815.tar.gz CMake-ddb1759b3e2b5c1b2c56734cd2ae0fa6dcf3a815.tar.bz2 |
Merge topic 'cmStringAlgorithms_move_functions'
959b97a27f Tests: testStringAlgorithms: Add cmTrimWhitespace, cmEscapeQuotes, cmTokenize
7fbcc16dcd cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenize
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3647
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLib/testStringAlgorithms.cxx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index 95616ff..55d2a8f 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -38,6 +38,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 { typedef std::string ST; @@ -52,6 +74,21 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) } // ---------------------------------------------------------------------- + // 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 { int ni = -1100; |