1/**
2 * Copyright (C) 2004, 2006 Brad Hards <bradh@frogmouth.net>
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <QtCrypto>
27#include <QtTest/QtTest>
28
29#include <limits>
30
31#ifdef QT_STATICPLUGIN
32#include "import_plugins.h"
33#endif
34
35class KeyLengthUnitTest : public QObject
36{
37 Q_OBJECT
38
39private Q_SLOTS:
40 void initTestCase();
41 void cleanupTestCase();
42 void doTest();
43
44private:
45 QCA::Initializer *m_init;
46};
47
48void KeyLengthUnitTest::initTestCase()
49{
50 m_init = new QCA::Initializer;
51}
52
53void KeyLengthUnitTest::cleanupTestCase()
54{
55 QCA::unloadAllPlugins();
56 delete m_init;
57}
58
59void KeyLengthUnitTest::doTest()
60{
61 QCA::KeyLength keylen1(0, 0, 0);
62 QCOMPARE(keylen1.minimum(), 0);
63 QCOMPARE(keylen1.maximum(), 0);
64 QCOMPARE(keylen1.multiple(), 0);
65
66 QCA::KeyLength keylen2(3, 40, 1);
67 QCOMPARE(keylen2.minimum(), 3);
68 QCOMPARE(keylen2.maximum(), 40);
69 QCOMPARE(keylen2.multiple(), 1);
70
71 QCA::KeyLength keylen3(1, INT_MAX, 1);
72 QCOMPARE(keylen3.minimum(), 1);
73 QCOMPARE(keylen3.maximum(), INT_MAX);
74 QCOMPARE(keylen3.multiple(), 1);
75}
76
77QTEST_MAIN(KeyLengthUnitTest)
78
79#include "keylengthunittest.moc"
80

source code of qca/unittest/keylengthunittest/keylengthunittest.cpp