Added new project that will be used for automatic testing for decoding/encoding functions.

This commit is contained in:
favoritas37 2016-01-10 14:56:52 +02:00
parent c54b7a61a4
commit f2a23c0a34
6 changed files with 148 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#include "DecodeValidator.h"
DecodeValidator::DecodeValidator() : decoder()
{
}
std::shared_ptr<ValidationStats> DecodeValidator::testDecodeWithExpectedOutput(QZXing::DecoderFormat enabledDecoder, const QImage &imageToDecode, const QString &expectedOutput)
{
std::shared_ptr<ValidationStats> stats_ = std::make_shared<ValidationStats>();
decoder.setDecoder(enabledDecoder);
QString result = decoder.decodeImage(imageToDecode, 999, 999, true);
stats_->setElaspedTime(decoder.getProcessTimeOfLastDecoding());
stats_->setOperationSuccess(result != "");
stats_->setResultMatch(result == expectedOutput);
return stats_;
}

View File

@ -0,0 +1,21 @@
#ifndef DECODEVALIDATOR_H
#define DECODEVALIDATOR_H
#include "ValidationStats.h"
#include <QZXing.h>
#include <memory>
class DecodeValidator
{
private:
QZXing decoder;
public:
DecodeValidator();
std::shared_ptr<ValidationStats> testDecodeWithExpectedOutput(QZXing::DecoderFormat enabledDecoder,
const QImage &imageToDecode,
const QString &expectedOutput);
};
#endif // DECODEVALIDATOR_H

View File

@ -0,0 +1,22 @@
QT += core
QT -= gui
CONFIG += gnu++11
TARGET = QZXingTests
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp \
DecodeValidator.cpp \
ValidationStats.cpp
HEADERS += \
DecodeValidator.h \
ValidationStats.h
include(../../../src/QZXing.pri)

View File

@ -0,0 +1,47 @@
#include "ValidationStats.h"
bool ValidationStats::getOperationSuccess() const
{
return operationSuccess;
}
void ValidationStats::setOperationSuccess(bool value)
{
operationSuccess = value;
}
bool ValidationStats::getResultMatch() const
{
return resultMatch;
}
void ValidationStats::setResultMatch(bool value)
{
resultMatch = value;
}
QString ValidationStats::getErrorMessage() const
{
return errorMessage;
}
void ValidationStats::setErrorMessage(const QString &value)
{
errorMessage = value;
}
int64_t ValidationStats::getElaspedTime() const
{
return elaspedTime;
}
void ValidationStats::setElaspedTime(const int64_t &value)
{
elaspedTime = value;
}
ValidationStats::ValidationStats()
{
}

View File

@ -0,0 +1,28 @@
#ifndef VALIDATIONSTATS_H
#define VALIDATIONSTATS_H
#include <QString>
#include <stdint.h>
class ValidationStats
{
private:
bool operationSuccess;
bool resultMatch;
QString errorMessage;
int64_t elaspedTime;
public:
ValidationStats();
bool getOperationSuccess() const;
bool getResultMatch() const;
QString getErrorMessage() const;
int64_t getElaspedTime() const;
void setOperationSuccess(bool value);
void setResultMatch(bool value);
void setErrorMessage(const QString &value);
void setElaspedTime(const int64_t &value);
};
#endif // VALIDATIONSTATS_H

View File

@ -0,0 +1,9 @@
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}