Improve printing details when writetest fails

This commit is contained in:
Daniel Novomeský 2025-02-09 10:54:02 +01:00
parent 9b14e752db
commit 9fd6896cec

View File

@ -46,11 +46,11 @@ QJsonObject readOptionalInfo(const QString &suffix)
return doc.object(); return doc.object();
} }
void setOptionalInfo(QImage& image, const QString &suffix) void setOptionalInfo(QImage &image, const QString &suffix)
{ {
auto obj = readOptionalInfo(suffix); auto obj = readOptionalInfo(suffix);
if (obj.isEmpty()) { if (obj.isEmpty()) {
return ; return;
} }
// Set resolution // 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); auto obj = readOptionalInfo(suffix);
if (obj.isEmpty()) { if (obj.isEmpty()) {
@ -258,7 +258,6 @@ QImage formatSourceImage(const QImage::Format &format)
auto folder = QStringLiteral("%1/format/_images").arg(IMAGEDIR); auto folder = QStringLiteral("%1/format/_images").arg(IMAGEDIR);
switch (format) { switch (format) {
case QImage::Format_MonoLSB: case QImage::Format_MonoLSB:
case QImage::Format_Mono: case QImage::Format_Mono:
image = QImage(QStringLiteral("%1/mono.png").arg(folder)); 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 // checking the format: must be the same
if (writtenImage.format() != tmplImage.format()) { if (writtenImage.format() != tmplImage.format()) {
++failed; ++failed;
auto writtenformatName = QString(QMetaEnum::fromType<QImage::Format>().valueToKey(writtenImage.format()));
auto tmplformatName = QString(QMetaEnum::fromType<QImage::Format>().valueToKey(tmplImage.format())); auto tmplformatName = QString(QMetaEnum::fromType<QImage::Format>().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; continue;
} }
@ -554,7 +561,7 @@ int nullDeviceTest(const QString &suffix)
writer.optimizedWrite(); writer.optimizedWrite();
writer.progressiveScanWrite(); writer.progressiveScanWrite();
if (failed == 0) {// success if (failed == 0) { // success
++passed; ++passed;
} }
@ -586,8 +593,7 @@ int main(int argc, char **argv)
QStringLiteral("max")); QStringLiteral("max"));
QCommandLineOption createFormatTempates({QStringLiteral("create-format-templates")}, QCommandLineOption createFormatTempates({QStringLiteral("create-format-templates")},
QStringLiteral("Create template images for all formats supported by QImage.")); QStringLiteral("Create template images for all formats supported by QImage."));
QCommandLineOption skipOptTest({QStringLiteral("skip-optional-tests")}, QCommandLineOption skipOptTest({QStringLiteral("skip-optional-tests")}, QStringLiteral("Skip optional data tests (metadata, resolution, etc.)."));
QStringLiteral("Skip optional data tests (metadata, resolution, etc.)."));
parser.addOption(lossless); parser.addOption(lossless);
parser.addOption(ignoreDataCheck); parser.addOption(ignoreDataCheck);