Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
None
-
4.7.0
-
None
-
Debian GNU/Linux squeeze, gcc 4.4.5
-
4a680036c4b52a58b89090657d61fb49a58e1d9a
Description
A typical variant of QCOMPARE macro (from the documentation).
void TestQString::toUpper() { QString str = "!Hello"; QCOMPARE(str.toUpper(), QString("HELLO")); }
In the log appears
FAIL! : TestQString::toUpper() Compared values are not the same Actual (str.toUpper()): !HELLO Expected (QString("HELLO")): HELLO Loc: [test.cpp(27)]
But QString in real program can be obtained as the result of tested functions and may be localized:
void TestQString::toUpper() { QString str =some_function(); QCOMPARE(str, QString("HELLO")); }
In the log appears
FAIL! : TestQString::toUpper() Compared values are not the same Actual (str): ????? Expected (QString("HELLO")): HELLO Loc: [test.cpp(27)]
In my system, I can watch the console localized strings, but deprived of this opportunity. This creates unnecessary hardships and difficult to debug.
I researched the problem and find function(src/testlib/qtestcase.cpp)
void filter_unprintable(char *str) { char *idx = str; while (*idx) { if (((*idx < 0x20 && *idx != '\n' && *idx != '\t') || *idx > 0x7e)) *idx = '?'; ++idx; } }
It seems the reason for such behavior in this function