AusweisApp2/test/qt/card/test_Command.cpp
2017-07-03 09:30:10 +02:00

78 lines
1.4 KiB
C++

/*!
* test_Command.cpp
*
* \brief Tests for card commands
*
* \copyright Copyright (c) 2014 Governikus GmbH & Co. KG
*/
#include <QtCore/QtCore>
#include <QtTest/QtTest>
#include "Commands.h"
#include "TestFileHelper.h"
using namespace governikus;
class test_Command
: public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase()
{
}
void testToBigEndian_fatInt()
{
QByteArray value = toBigEndian(static_cast<int>(0xFFEE));
QCOMPARE(value.size(), 2);
QCOMPARE(value.at(0), char(0xFF));
QCOMPARE(value.at(1), char(0xEE));
}
void testToBigEndian_int()
{
QByteArray value = toBigEndian(static_cast<int>(0x11));
QCOMPARE(value.size(), 1);
QCOMPARE(value.at(0), static_cast<char>(0x11));
}
void testToBigEndian_zero()
{
QByteArray value = toBigEndian(static_cast<int>(0x00));
QCOMPARE(value.size(), 1);
QCOMPARE(value.at(0), static_cast<char>(0x00));
}
void testToBigEndian_long()
{
QByteArray value = toBigEndian(static_cast<long>(0x11));
QCOMPARE(value.size(), 1);
QCOMPARE(value.at(0), static_cast<char>(0x11));
}
void testPinModifyBuilder_createChangeEidPinCommandData()
{
PinModifyBuilder builder;
unsigned int timeout = 77;
QCOMPARE(builder.createChangeEidPinCommandData(timeout), QByteArray::fromHex("82000000000606010202070400010200000004000000002C0203").prepend(timeout).prepend(timeout));
}
};
QTEST_GUILESS_MAIN(test_Command)
#include "test_Command.moc"