mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
read autotest: write out data when comparison fails
This helps with debugging, as we can just grab the data rather than using imageconvertor. Reviewed-by: David Faure
This commit is contained in:
parent
b4192f9f8b
commit
6d24f585b1
@ -29,6 +29,26 @@
|
||||
#include <QImageReader>
|
||||
#include <QTextStream>
|
||||
|
||||
static void writeImageData(const char *name, const QString &filename, const QImage &image)
|
||||
{
|
||||
QFile file(filename);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
qint64 written = file.write(reinterpret_cast<const char *>(image.bits()), image.byteCount());
|
||||
if (written == image.byteCount()) {
|
||||
QTextStream(stdout) << " " << name
|
||||
<< " written to " << filename << "\n";
|
||||
} else {
|
||||
QTextStream(stdout) << " could not write " << name
|
||||
<< " to " << filename << ":"
|
||||
<< file.errorString() << "\n";
|
||||
}
|
||||
} else {
|
||||
QTextStream(stdout) << " could not open "
|
||||
<< filename << ":"
|
||||
<< file.errorString() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
@ -99,6 +119,12 @@ int main(int argc, char ** argv)
|
||||
if (expImage != inputImage) {
|
||||
QTextStream(stdout) << "FAIL : " << fi.fileName()
|
||||
<< ": differs from " << expfilename << "\n";
|
||||
writeImageData("expected data",
|
||||
fi.fileName() + QLatin1String("-expected.data"),
|
||||
expImage);
|
||||
writeImageData("actual data",
|
||||
fi.fileName() + QLatin1String("-actual.data"),
|
||||
inputImage);
|
||||
++failed;
|
||||
} else {
|
||||
QTextStream(stdout) << "PASS : " << fi.fileName() << "\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user