From 9fd6896cec3af763104333910cf7e2254b19d144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Sun, 9 Feb 2025 10:54:02 +0100 Subject: [PATCH] Improve printing details when writetest fails --- autotests/writetest.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/autotests/writetest.cpp b/autotests/writetest.cpp index ab2db9d..10a3df8 100644 --- a/autotests/writetest.cpp +++ b/autotests/writetest.cpp @@ -46,11 +46,11 @@ QJsonObject readOptionalInfo(const QString &suffix) return doc.object(); } -void setOptionalInfo(QImage& image, const QString &suffix) +void setOptionalInfo(QImage &image, const QString &suffix) { auto obj = readOptionalInfo(suffix); if (obj.isEmpty()) { - return ; + return; } // Set resolution @@ -70,7 +70,7 @@ void setOptionalInfo(QImage& image, const QString &suffix) } } -bool checkOptionalInfo(QImage& image, const QString &suffix) +bool checkOptionalInfo(QImage &image, const QString &suffix) { auto obj = readOptionalInfo(suffix); if (obj.isEmpty()) { @@ -258,7 +258,6 @@ QImage formatSourceImage(const QImage::Format &format) auto folder = QStringLiteral("%1/format/_images").arg(IMAGEDIR); switch (format) { - case QImage::Format_MonoLSB: case QImage::Format_Mono: image = QImage(QStringLiteral("%1/mono.png").arg(folder)); @@ -403,8 +402,16 @@ int formatTest(const QString &suffix, bool createTemplates) // checking the format: must be the same if (writtenImage.format() != tmplImage.format()) { ++failed; + auto writtenformatName = QString(QMetaEnum::fromType().valueToKey(writtenImage.format())); auto tmplformatName = QString(QMetaEnum::fromType().valueToKey(tmplImage.format())); - QTextStream(stdout) << "FAIL : format mismatch " << formatName << " != " << tmplformatName << "\n"; + QTextStream(stdout) << "FAIL : format mismatch " << formatName << " ("; + if (format == writtenImage.format()) { + QTextStream(stdout) << "template image: " << tmplformatName << ")\n"; + } else if (format == tmplImage.format()) { + QTextStream(stdout) << "written image: " << writtenformatName << ")\n"; + } else { + QTextStream(stdout) << writtenformatName << " != " << tmplformatName << ")\n"; + } continue; } @@ -554,7 +561,7 @@ int nullDeviceTest(const QString &suffix) writer.optimizedWrite(); writer.progressiveScanWrite(); - if (failed == 0) {// success + if (failed == 0) { // success ++passed; } @@ -586,8 +593,7 @@ int main(int argc, char **argv) QStringLiteral("max")); QCommandLineOption createFormatTempates({QStringLiteral("create-format-templates")}, QStringLiteral("Create template images for all formats supported by QImage.")); - QCommandLineOption skipOptTest({QStringLiteral("skip-optional-tests")}, - QStringLiteral("Skip optional data tests (metadata, resolution, etc.).")); + QCommandLineOption skipOptTest({QStringLiteral("skip-optional-tests")}, QStringLiteral("Skip optional data tests (metadata, resolution, etc.).")); parser.addOption(lossless); parser.addOption(ignoreDataCheck);