2004-11-09 09:00:22 +00:00
|
|
|
/**
|
2006-03-26 06:08:00 +00:00
|
|
|
* Copyright (C) 2004, 2006 Brad Hards <bradh@frogmouth.net>
|
2004-11-09 09:00:22 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
2006-10-12 05:10:06 +00:00
|
|
|
|
2005-01-01 05:11:34 +00:00
|
|
|
#include <QtCrypto>
|
2006-10-12 05:10:06 +00:00
|
|
|
#include <QtTest/QtTest>
|
2005-01-01 04:20:34 +00:00
|
|
|
|
2004-11-09 09:00:22 +00:00
|
|
|
#include <limits>
|
|
|
|
|
2014-01-02 03:50:18 +06:00
|
|
|
#ifdef QT_STATICPLUGIN
|
|
|
|
#include "import_plugins.h"
|
|
|
|
#endif
|
|
|
|
|
2006-10-12 05:10:06 +00:00
|
|
|
class KeyLengthUnitTest : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void initTestCase();
|
|
|
|
void cleanupTestCase();
|
|
|
|
void doTest();
|
|
|
|
private:
|
|
|
|
QCA::Initializer* m_init;
|
|
|
|
};
|
|
|
|
|
2006-03-26 06:08:00 +00:00
|
|
|
void KeyLengthUnitTest::initTestCase()
|
2004-11-09 09:00:22 +00:00
|
|
|
{
|
2006-03-26 06:08:00 +00:00
|
|
|
m_init = new QCA::Initializer;
|
2004-11-09 09:00:22 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 06:08:00 +00:00
|
|
|
void KeyLengthUnitTest::cleanupTestCase()
|
2004-11-09 09:00:22 +00:00
|
|
|
{
|
2006-03-26 06:08:00 +00:00
|
|
|
QCA::unloadAllPlugins();
|
|
|
|
delete m_init;
|
|
|
|
}
|
2004-11-09 09:00:22 +00:00
|
|
|
|
2006-03-26 06:08:00 +00:00
|
|
|
void KeyLengthUnitTest::doTest()
|
|
|
|
{
|
2004-11-09 09:00:22 +00:00
|
|
|
QCA::KeyLength keylen1( 0, 0, 0 );
|
2006-03-26 06:08:00 +00:00
|
|
|
QCOMPARE( keylen1.minimum(), 0 );
|
|
|
|
QCOMPARE( keylen1.maximum(), 0 );
|
|
|
|
QCOMPARE( keylen1.multiple(), 0 );
|
2004-11-09 09:00:22 +00:00
|
|
|
|
|
|
|
QCA::KeyLength keylen2( 3, 40, 1 );
|
2006-03-26 06:08:00 +00:00
|
|
|
QCOMPARE( keylen2.minimum(), 3 );
|
|
|
|
QCOMPARE( keylen2.maximum(), 40 );
|
|
|
|
QCOMPARE( keylen2.multiple(), 1 );
|
2004-11-09 09:00:22 +00:00
|
|
|
|
2005-07-07 21:24:33 +00:00
|
|
|
QCA::KeyLength keylen3( 1, INT_MAX, 1 );
|
2006-03-26 06:08:00 +00:00
|
|
|
QCOMPARE( keylen3.minimum(), 1 );
|
|
|
|
QCOMPARE( keylen3.maximum(), INT_MAX );
|
|
|
|
QCOMPARE( keylen3.multiple(), 1 );
|
2004-11-09 09:00:22 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-03-26 06:08:00 +00:00
|
|
|
QTEST_MAIN(KeyLengthUnitTest)
|
2006-10-12 05:10:06 +00:00
|
|
|
|
|
|
|
#include "keylengthunittest.moc"
|