Fix test for compilers not supporting \u escapes in strings (such as VC6).
Also reformat the code to follow wx style and explicitly use UTF-8 for the test strings encoding instead of assuming the encoding of the current locale was UTF-8 (which is never the case under Windows). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63685 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -49,30 +49,66 @@ void EllipsizationTestCase::Ellipsize()
|
||||
{
|
||||
wxMemoryDC dc;
|
||||
|
||||
wxString stringsToTest[] =
|
||||
static const char *stringsToTest[] =
|
||||
{
|
||||
"N", ".", "x", "foobar", wxS("\u03B1"), "Another test", "a very very very very very very very long string",
|
||||
"\xCE\xB1\xCE\xB2\xCE\xB3\xCE\xB4\xCE\xB5\xCE\xB6\xCE\xB7\xCE\xB8\xCE\xB9",
|
||||
"N",
|
||||
".",
|
||||
"x",
|
||||
"foobar",
|
||||
"\xCE\xB1", // U03B1 (GREEK SMALL LETTER ALPHA)
|
||||
"Another test",
|
||||
"a very very very very very very very long string",
|
||||
// alpha+beta+gamma+delta+epsilon+zeta+eta+theta+iota
|
||||
"\xCE\xB1\xCE\xB2\xCE\xB3\xCE\xB4\xCE\xB5\xCE\xB6\xCE\xB7\xCE\xB8\xCE\xB9",
|
||||
"\t", "\t\t\t\t\t", "a\tstring\twith\ttabs",
|
||||
"\n", "\n\n\n\n\n", "a\nstring\nwith\nnewlines",
|
||||
"&", "&&&&&&&", "a&string&with&newlines",
|
||||
"\t\n&", "a\t\n&string\t\n&with\t\n&many\t\n&chars"
|
||||
};
|
||||
int flagsToTest[] = { 0, wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS, wxELLIPSIZE_FLAGS_EXPAND_TABS,
|
||||
wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS|wxELLIPSIZE_FLAGS_EXPAND_TABS };
|
||||
wxEllipsizeMode modesToTest[] = { wxELLIPSIZE_START, wxELLIPSIZE_MIDDLE, wxELLIPSIZE_END };
|
||||
|
||||
static const int flagsToTest[] =
|
||||
{
|
||||
0,
|
||||
wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS,
|
||||
wxELLIPSIZE_FLAGS_EXPAND_TABS,
|
||||
wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS | wxELLIPSIZE_FLAGS_EXPAND_TABS
|
||||
};
|
||||
|
||||
static const wxEllipsizeMode modesToTest[] =
|
||||
{
|
||||
wxELLIPSIZE_START,
|
||||
wxELLIPSIZE_MIDDLE,
|
||||
wxELLIPSIZE_END
|
||||
};
|
||||
|
||||
int widthsToTest[] = { 0, 1, 2, 3, 10, 20, 100 };
|
||||
|
||||
for ( unsigned int s = 0; s < WXSIZEOF(stringsToTest); s++ )
|
||||
{
|
||||
const wxString str = wxString::FromUTF8(stringsToTest[s]);
|
||||
|
||||
for ( unsigned int f = 0; f < WXSIZEOF(flagsToTest); f++ )
|
||||
{
|
||||
for ( unsigned int m = 0; m < WXSIZEOF(modesToTest); m++ )
|
||||
{
|
||||
for ( unsigned int w = 0; w < WXSIZEOF(widthsToTest); w++ )
|
||||
{
|
||||
wxString ret = wxControlBase::Ellipsize(stringsToTest[s], dc, modesToTest[m],
|
||||
widthsToTest[w], flagsToTest[f]);
|
||||
wxString ret = wxControlBase::Ellipsize
|
||||
(
|
||||
str,
|
||||
dc,
|
||||
modesToTest[m],
|
||||
widthsToTest[w],
|
||||
flagsToTest[f]
|
||||
);
|
||||
|
||||
CPPUNIT_ASSERT_MESSAGE((std::string)("invalid ellipsization for: " + stringsToTest[s]),
|
||||
dc.GetMultiLineTextExtent(ret).GetWidth() <= widthsToTest[w]);
|
||||
WX_ASSERT_MESSAGE
|
||||
(
|
||||
("invalid ellipsization for \"%s\"", str),
|
||||
dc.GetMultiLineTextExtent(ret).GetWidth() <= widthsToTest[w]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user