Skip to content

Commit 37d0dc8

Browse files
committed
#164-Test CppStringT::rjust() with char and wchar_t
Completed. Validated.
1 parent e3cf5e3 commit 37d0dc8

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,5 +2270,52 @@ namespace cppstringstests
22702270
Assert::AreEqual(L"..abc", ws.rjust(5, '.').c_str());
22712271
}
22722272

2273+
TEST_METHOD(rpartition)
2274+
{
2275+
pcs::CppString s("abcd#123efg#123hij");
2276+
std::vector<CppString> res{ s.rpartition("#123") };
2277+
Assert::AreEqual("abcd#123efg", res[0].c_str());
2278+
Assert::AreEqual("#123", res[1].c_str());
2279+
Assert::AreEqual("hij", res[2].c_str());
2280+
2281+
s = "abcd#123fgh#123";
2282+
res = s.rpartition("#123");
2283+
Assert::AreEqual("abcd#123fgh", res[0].c_str());
2284+
Assert::AreEqual("#123", res[1].c_str());
2285+
Assert::AreEqual("", res[2].c_str());
2286+
2287+
res = s.rpartition("XYZ");
2288+
Assert::AreEqual("abcd#123fgh#123", res[0].c_str());
2289+
Assert::AreEqual("", res[1].c_str());
2290+
Assert::AreEqual("", res[2].c_str());
2291+
2292+
res = ""cs.rpartition("A");
2293+
Assert::AreEqual("", res[0].c_str());
2294+
Assert::AreEqual("", res[1].c_str());
2295+
Assert::AreEqual("", res[2].c_str());
2296+
2297+
pcs::CppWString ws(L"abcd#123efg#123hij");
2298+
std::vector<CppWString> wres{ ws.rpartition(L"#123") };
2299+
Assert::AreEqual(L"abcd#123efg", wres[0].c_str());
2300+
Assert::AreEqual(L"#123", wres[1].c_str());
2301+
Assert::AreEqual(L"hij", wres[2].c_str());
2302+
2303+
ws = L"abcd#123fgh#123";
2304+
wres = ws.rpartition(L"#123");
2305+
Assert::AreEqual(L"abcd#123fgh", wres[0].c_str());
2306+
Assert::AreEqual(L"#123", wres[1].c_str());
2307+
Assert::AreEqual(L"", wres[2].c_str());
2308+
2309+
wres = ws.rpartition(L"XYZ");
2310+
Assert::AreEqual(L"abcd#123fgh#123", wres[0].c_str());
2311+
Assert::AreEqual(L"", wres[1].c_str());
2312+
Assert::AreEqual(L"", wres[2].c_str());
2313+
2314+
wres = L""cs.rpartition(L"A");
2315+
Assert::AreEqual(L"", wres[0].c_str());
2316+
Assert::AreEqual(L"", wres[1].c_str());
2317+
Assert::AreEqual(L"", wres[2].c_str());
2318+
}
2319+
22732320
};
22742321
}

0 commit comments

Comments
 (0)