1 /****************************************************************************
3 ** Copyright (C) 2014 Kurt Pattyn <pattyn.kurt@gmail.com>.
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL21$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
26 ** In addition, as a special exception, Digia gives you certain additional
27 ** rights. These rights are described in the Digia Qt LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
32 ****************************************************************************/
33 #include <QtTest/QtTest>
34 #include <QtTest/qtestcase.h>
35 #include <QtTest/QSignalSpy>
36 #include <QtCore/QBuffer>
37 #include <QtCore/QByteArray>
38 #include <QtCore/QDebug>
40 #include "private/qdefaultmaskgenerator_p.h"
44 class tst_QDefaultMaskGenerator : public QObject
49 tst_QDefaultMaskGenerator();
53 void cleanupTestCase();
57 void tst_randomnessWithoutSeed();
58 void tst_randomnessWithSeed();
65 tst_QDefaultMaskGenerator::tst_QDefaultMaskGenerator()
69 void tst_QDefaultMaskGenerator::initTestCase()
73 void tst_QDefaultMaskGenerator::cleanupTestCase()
77 void tst_QDefaultMaskGenerator::init()
81 void tst_QDefaultMaskGenerator::cleanup()
85 void tst_QDefaultMaskGenerator::tst_randomnessWithoutSeed()
87 //generate two series of data, and see if they differ
89 QDefaultMaskGenerator generator;
91 QVector<quint32> series1, series2;
92 for (int i = 0; i < 1000; ++i)
93 series1 << generator.nextMask();
94 for (int i = 0; i < 1000; ++i)
95 series2 << generator.nextMask();
97 QVERIFY(series1 != series2);
101 void tst_QDefaultMaskGenerator::tst_randomnessWithSeed()
103 //generate two series of data, and see if they differ
104 //the generator is seeded
106 QDefaultMaskGenerator generator;
109 QVector<quint32> series1, series2;
110 for (int i = 0; i < 1000; ++i)
111 series1 << generator.nextMask();
112 for (int i = 0; i < 1000; ++i)
113 series2 << generator.nextMask();
115 QVERIFY(series1 != series2);
117 //generates two series of data with 2 distinct generators
118 //both generators are seeded
120 QDefaultMaskGenerator generator1, generator2;
124 QVector<quint32> series1, series2;
125 for (int i = 0; i < 1000; ++i) {
126 series1 << generator1.nextMask();
127 series2 << generator2.nextMask();
130 QVERIFY(series1 != series2);
132 //generates two series of data with 2 distinct generators
133 //only one of the two is seeded
135 QDefaultMaskGenerator generator1, generator2;
138 QVector<quint32> series1, series2;
139 for (int i = 0; i < 1000; ++i) {
140 series1 << generator1.nextMask();
141 series2 << generator2.nextMask();
144 QVERIFY(series1 != series2);
148 QTEST_MAIN(tst_QDefaultMaskGenerator)
150 #include "tst_defaultmaskgenerator.moc"