Skip to content

Commit 19d9688

Browse files
committed
#166-Test CppStringT::rsplit() with char and wchar_t
Fixed erroneous doxygen string. Added related tests.
1 parent 80c3288 commit 19d9688

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

cpp-strings-tests/cpp-strings-tests.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,17 @@ namespace cppstringstests
24272427
Assert::AreEqual("", res[7].c_str());
24282428
Assert::AreEqual("", res[8].c_str());
24292429

2430+
s = pcs::CppString(5, ' '); //" "cs;
2431+
res = s.rsplit();
2432+
Assert::AreEqual(pcs::CppString::size_type(6), res.size());
2433+
Assert::AreEqual("", res[0].c_str());
2434+
Assert::AreEqual("", res[1].c_str());
2435+
Assert::AreEqual("", res[2].c_str());
2436+
Assert::AreEqual("", res[3].c_str());
2437+
Assert::AreEqual("", res[4].c_str());
2438+
Assert::AreEqual("", res[5].c_str());
2439+
2440+
24302441
s = " abcd#123efg#123hij #123#123klmn "cs;
24312442
res = s.rsplit("#123");
24322443
Assert::AreEqual(pcs::CppString::size_type(5), res.size());
@@ -2650,6 +2661,16 @@ namespace cppstringstests
26502661
Assert::AreEqual(L"", wres[7].c_str());
26512662
Assert::AreEqual(L"", wres[8].c_str());
26522663

2664+
ws = pcs::CppWString(5, ' '); //L" "cs;
2665+
wres = ws.rsplit();
2666+
Assert::AreEqual(pcs::CppWString::size_type(6), wres.size());
2667+
Assert::AreEqual(L"", wres[0].c_str());
2668+
Assert::AreEqual(L"", wres[1].c_str());
2669+
Assert::AreEqual(L"", wres[2].c_str());
2670+
Assert::AreEqual(L"", wres[3].c_str());
2671+
Assert::AreEqual(L"", wres[4].c_str());
2672+
Assert::AreEqual(L"", wres[5].c_str());
2673+
26532674
ws = L" abcd#123efg#123hij #123#123klmn "cs;
26542675
wres = ws.rsplit(L"#123");
26552676
Assert::AreEqual(pcs::CppWString::size_type(5), wres.size());

cpp-strings/cppstrings.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,12 +1406,8 @@ namespace pcs // i.e. "pythonic c++ strings"
14061406
//--- rsplit() ----------------------------------------
14071407
/** \brief Returns a vector of the words in the whole string, as seperated with whitespace strings.
14081408
*
1409-
* Notice: runs of consecutive whitespace are regarded as a single
1410-
* separator, and the result will contain no empty strings at the
1411-
* start or end if the string has leading or trailing whitespace.
1412-
* Consequently, splitting an empty string or a string consisting
1413-
* of just whitespace with a whitespace separator returns an empty
1414-
* vector.
1409+
* Notice: consecutive whitespaces are each regarded as a
1410+
* single separator. So, they each separate empty strings.
14151411
*/
14161412
inline std::vector<CppStringT> rsplit() noexcept
14171413
{

0 commit comments

Comments
 (0)