AusweisApp2/test/qt/global/test_CardReturnCode.cpp

57 lines
1.3 KiB
C++
Raw Normal View History

2017-07-03 09:33:28 +02:00
/*!
* \brief Unit tests for return codes.
*
2018-03-28 15:10:51 +02:00
* \copyright Copyright (c) 2014-2018 Governikus GmbH & Co. KG, Germany
2017-07-03 09:33:28 +02:00
*/
2017-12-20 14:54:05 +01:00
#include "CardReturnCode.h"
#include "Result.h"
2017-07-03 09:33:28 +02:00
#include <QPair>
#include <QString>
#include <QtTest>
using namespace governikus;
class test_CardReturnCode
: public QObject
{
Q_OBJECT
private Q_SLOTS:
void check_errorCodeToMessage()
{
QCOMPARE(CardReturnCodeUtil::toGlobalStatus(CardReturnCode::CANCELLATION_BY_USER).toErrorDescription(),
QString("The process was cancelled by the user."));
}
void check_errorCodeToResult()
{
QCOMPARE(Result(CardReturnCodeUtil::toGlobalStatus(CardReturnCode::CANCELLATION_BY_USER)).getMinor(), GlobalStatus::Code::Paos_Error_SAL_Cancellation_by_User);
}
void check_errorCodeToError()
{
const Result& result = Result(CardReturnCodeUtil::toGlobalStatus(CardReturnCode::CANCELLATION_BY_USER));
QCOMPARE(result.getMinor(), GlobalStatus::Code::Paos_Error_SAL_Cancellation_by_User);
QCOMPARE(result.getMessage(), QString("The process was cancelled by the user."));
}
void checkConsistency()
{
for (auto returnCode : Enum<CardReturnCode>::getList())
{
QVERIFY(!CardReturnCodeUtil::toGlobalStatus(returnCode).toErrorDescription().isEmpty());
}
}
};
QTEST_GUILESS_MAIN(test_CardReturnCode)
#include "test_CardReturnCode.moc"