summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2012-03-08 11:30:10 +1000
committerQt by Nokia <qt-info@nokia.com>2012-03-12 01:50:20 +0100
commita4c0109e016709dbeea1497cd122722e5ec5e26b (patch)
treea07332de538b15bdbadb044b52f9d8bd8e6c8242 /src
parent15c13b91e66b0bd0d179f0303bb17c7793f80a07 (diff)
testlib: Improve formatting of QCOMPARE failure messages.
Make the various versions of the failure message align consistently so that it's a little easier to compare the actual and expected values. Of course, the value won't align nicely unless the "actual" and "expected" strings are the same length, but at least this commit makes that consistent across all versions of the message. Change-Id: If9ce231df3b5d279a06f6458fdb5da0aa4586068 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/testlib/qtest.h6
-rw-r--r--src/testlib/qtest_gui.h10
-rw-r--r--src/testlib/qtestresult.cpp2
3 files changed, 9 insertions, 9 deletions
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index 477d344d71..d167324aef 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -197,15 +197,15 @@ inline bool qCompare(QStringList const &t1, QStringList const &t2,
const int expectedSize = t2.count();
if (actualSize != expectedSize) {
qsnprintf(msg, sizeof(msg), "Compared QStringLists have different sizes.\n"
- " Actual (%s) size : '%d'\n"
+ " Actual (%s) size: '%d'\n"
" Expected (%s) size: '%d'", actual, actualSize, expected, expectedSize);
isOk = false;
}
for (int i = 0; isOk && i < actualSize; ++i) {
if (t1.at(i) != t2.at(i)) {
qsnprintf(msg, sizeof(msg), "Compared QStringLists differ at index %d.\n"
- " Actual (%s) : '%s'\n"
- " Expected (%s) : '%s'", i, actual, t1.at(i).toLatin1().constData(),
+ " Actual (%s): '%s'\n"
+ " Expected (%s): '%s'", i, actual, t1.at(i).toLatin1().constData(),
expected, t2.at(i).toLatin1().constData());
isOk = false;
}
diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h
index 3067c35e02..f10ddd8473 100644
--- a/src/testlib/qtest_gui.h
+++ b/src/testlib/qtest_gui.h
@@ -100,7 +100,7 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
const bool t2Null = t2.isNull();
if (t1Null != t2Null) {
qsnprintf(msg, 1024, "Compared QImages differ.\n"
- " Actual (%s).isNull() : %d\n"
+ " Actual (%s).isNull(): %d\n"
" Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null);
return compare_helper(false, msg, 0, 0, actual, expected, file, line);
}
@@ -108,7 +108,7 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
return compare_helper(true, 0, 0, 0, actual, expected, file, line);
if (t1.width() != t2.width() || t2.height() != t2.height()) {
qsnprintf(msg, 1024, "Compared QImages differ in size.\n"
- " Actual (%s) : %dx%d\n"
+ " Actual (%s): %dx%d\n"
" Expected (%s): %dx%d",
actual, t1.width(), t1.height(),
expected, t2.width(), t2.height());
@@ -116,7 +116,7 @@ inline bool qCompare(QImage const &t1, QImage const &t2,
}
if (t1.format() != t2.format()) {
qsnprintf(msg, 1024, "Compared QImages differ in format.\n"
- " Actual (%s) : %d\n"
+ " Actual (%s): %d\n"
" Expected (%s): %d",
actual, t1.format(), expected, t2.format());
return compare_helper(false, msg, 0, 0, actual, expected, file, line);
@@ -137,7 +137,7 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
const bool t2Null = t2.isNull();
if (t1Null != t2Null) {
qsnprintf(msg, 1024, "Compared QPixmaps differ.\n"
- " Actual (%s).isNull() : %d\n"
+ " Actual (%s).isNull(): %d\n"
" Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null);
return compare_helper(false, msg, 0, 0, actual, expected, file, line);
}
@@ -145,7 +145,7 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c
return compare_helper(true, 0, 0, 0, actual, expected, file, line);
if (t1.width() != t2.width() || t2.height() != t2.height()) {
qsnprintf(msg, 1024, "Compared QPixmaps differ in size.\n"
- " Actual (%s) : %dx%d\n"
+ " Actual (%s): %dx%d\n"
" Expected (%s): %dx%d",
actual, t1.width(), t1.height(),
expected, t2.width(), t2.height());
diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp
index cbededfee2..9d62a9eb57 100644
--- a/src/testlib/qtestresult.cpp
+++ b/src/testlib/qtestresult.cpp
@@ -277,7 +277,7 @@ bool QTestResult::compare(bool success, const char *failureMsg,
if (success && QTest::expectFailMode) {
qsnprintf(msg, 1024, "QCOMPARE(%s, %s) returned TRUE unexpectedly.", actual, expected);
} else if (val1 || val2) {
- qsnprintf(msg, 1024, "%s\n Actual (%s): %s\n Expected (%s): %s",
+ qsnprintf(msg, 1024, "%s\n Actual (%s): %s\n Expected (%s): %s",
failureMsg,
actual, val1 ? val1 : "<null>",
expected, val2 ? val2 : "<null>");