mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-12 22:03:43 -06:00
upptst: MtDraw
git-svn-id: svn://ultimatepp.org/upp/trunk@5552 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ec99680986
commit
b2baae474d
6 changed files with 125 additions and 0 deletions
37
upptst/StringUtil/StringUtil.cpp
Normal file
37
upptst/StringUtil/StringUtil.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include <Core/Core.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
void TestTrimLeft(String what, String s, String r)
|
||||
{
|
||||
for(int i = 0; i < 3; i++) {
|
||||
ASSERT(TrimLeft(what, s) == r);
|
||||
ASSERT(TrimLeft(~what, s) == r);
|
||||
ASSERT(TrimLeft(~what, what.GetLength(), s) == r);
|
||||
r = s;
|
||||
what = i == 1 ? "<notfound\1>" : "";
|
||||
}
|
||||
}
|
||||
|
||||
void TestTrimRight(String what, String s, String r)
|
||||
{
|
||||
for(int i = 0; i < 3; i++) {
|
||||
ASSERT(TrimRight(what, s) == r);
|
||||
ASSERT(TrimRight(~what, s) == r);
|
||||
ASSERT(TrimRight(~what, what.GetLength(), s) == r);
|
||||
r = s;
|
||||
what = i == 1 ? "<notfound\1>" : "";
|
||||
}
|
||||
}
|
||||
|
||||
CONSOLE_APP_MAIN
|
||||
{
|
||||
String h = "http://www.website.org";
|
||||
DDUMP(TrimLeft("test", h));
|
||||
DDUMP(TrimLeft("http://", h));
|
||||
DDUMP(TrimRight("test", h));
|
||||
DDUMP(TrimRight(".org", h));
|
||||
|
||||
TestTrimLeft("http://", "http://www.website.org", "www.website.org");
|
||||
TestTrimRight(".org", "www.website.org", "www.website");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue