mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-07-17 11:44:16 -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:
@ -29,6 +29,26 @@
|
|||||||
#include <QImageReader>
|
#include <QImageReader>
|
||||||
#include <QTextStream>
|
#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)
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
QCoreApplication app(argc, argv);
|
||||||
@ -99,6 +119,12 @@ int main(int argc, char ** argv)
|
|||||||
if (expImage != inputImage) {
|
if (expImage != inputImage) {
|
||||||
QTextStream(stdout) << "FAIL : " << fi.fileName()
|
QTextStream(stdout) << "FAIL : " << fi.fileName()
|
||||||
<< ": differs from " << expfilename << "\n";
|
<< ": differs from " << expfilename << "\n";
|
||||||
|
writeImageData("expected data",
|
||||||
|
fi.fileName() + QLatin1String("-expected.data"),
|
||||||
|
expImage);
|
||||||
|
writeImageData("actual data",
|
||||||
|
fi.fileName() + QLatin1String("-actual.data"),
|
||||||
|
inputImage);
|
||||||
++failed;
|
++failed;
|
||||||
} else {
|
} else {
|
||||||
QTextStream(stdout) << "PASS : " << fi.fileName() << "\n";
|
QTextStream(stdout) << "PASS : " << fi.fileName() << "\n";
|
||||||
|
Reference in New Issue
Block a user