mirror of
https://github.com/status-im/qzxing.git
synced 2025-02-04 15:14:33 +00:00
Added new project that will be used for automatic testing for decoding/encoding functions.
This commit is contained in:
parent
c54b7a61a4
commit
f2a23c0a34
21
tests/src/QZXingTests/DecodeValidator.cpp
Normal file
21
tests/src/QZXingTests/DecodeValidator.cpp
Normal 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_;
|
||||
}
|
||||
|
21
tests/src/QZXingTests/DecodeValidator.h
Normal file
21
tests/src/QZXingTests/DecodeValidator.h
Normal 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
|
22
tests/src/QZXingTests/QZXingTests.pro
Normal file
22
tests/src/QZXingTests/QZXingTests.pro
Normal 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)
|
47
tests/src/QZXingTests/ValidationStats.cpp
Normal file
47
tests/src/QZXingTests/ValidationStats.cpp
Normal 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()
|
||||
{
|
||||
|
||||
}
|
||||
|
28
tests/src/QZXingTests/ValidationStats.h
Normal file
28
tests/src/QZXingTests/ValidationStats.h
Normal 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
|
9
tests/src/QZXingTests/main.cpp
Normal file
9
tests/src/QZXingTests/main.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include <QCoreApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user