AusweisApp2/test/qt/global/test_CardReturnCode.cpp

58 lines
1.4 KiB
C++
Raw Normal View History

2017-07-03 09:33:28 +02:00
/*!
* \brief Unit tests for return codes.
*
2019-05-22 10:08:38 +02:00
* \copyright Copyright (c) 2014-2019 Governikus GmbH & Co. KG, Germany
2017-07-03 09:33:28 +02:00
*/
2017-12-20 14:54:05 +01:00
#include "CardReturnCode.h"
2019-01-03 15:06:22 +01:00
#include "ECardApiResult.h"
2017-12-20 14:54:05 +01:00
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()
{
2019-01-03 15:06:22 +01:00
QCOMPARE(ECardApiResult(CardReturnCodeUtil::toGlobalStatus(CardReturnCode::CANCELLATION_BY_USER)).getMinor(), ECardApiResult::Minor::SAL_Cancellation_by_User);
2017-07-03 09:33:28 +02:00
}
void check_errorCodeToError()
{
2019-01-03 15:06:22 +01:00
const ECardApiResult& result = ECardApiResult(CardReturnCodeUtil::toGlobalStatus(CardReturnCode::CANCELLATION_BY_USER));
QCOMPARE(result.getMinor(), ECardApiResult::Minor::SAL_Cancellation_by_User);
2017-07-03 09:33:28 +02:00
QCOMPARE(result.getMessage(), QString("The process was cancelled by the user."));
}
void checkConsistency()
{
2019-09-30 17:22:19 +02:00
const auto list = Enum<CardReturnCode>::getList();
for (auto returnCode : list)
2017-07-03 09:33:28 +02:00
{
QVERIFY(!CardReturnCodeUtil::toGlobalStatus(returnCode).toErrorDescription().isEmpty());
}
}
};
QTEST_GUILESS_MAIN(test_CardReturnCode)
#include "test_CardReturnCode.moc"