Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TestPasswordGenerator.cpp « TestPasswordGenerator « tests « src - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6d7e80291565edac4bcd2c162ea90d98c32367f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2005-2020 The Mumble Developers. All rights reserved.
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file at the root of the
// Mumble source tree or at <https://www.mumble.info/LICENSE>.

#include <QtCore>
#include <QtTest>

#include "SSL.h"

#include "PasswordGenerator.h"

// Get the password alphabet from PasswordGenerator.
extern QVector< QChar > mumble_password_generator_alphabet();

class TestPasswordGenerator : public QObject {
	Q_OBJECT
private slots:
	void initTestCase();
	void cleanupTestCase();
	void random();
};

void TestPasswordGenerator::initTestCase() {
	MumbleSSL::initialize();
}

void TestPasswordGenerator::cleanupTestCase() {
	MumbleSSL::destroy();
}

void TestPasswordGenerator::random() {
	QVector< QChar > alphabet = mumble_password_generator_alphabet();
	for (int i = 0; i < 100; i++) {
		QString out = PasswordGenerator::generatePassword(i);
		QVERIFY(out.size() == i);
		for (int j = 0; j < out.size(); j++) {
			QVERIFY(alphabet.contains(out.at(j)));
		}
	}
}

QTEST_MAIN(TestPasswordGenerator)
#include "TestPasswordGenerator.moc"