Falkon Develop
Cross-platform Qt-based web browser
updatertest.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2013-2014 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "updatertest.h"
19#include "updater.h"
20
21#include <QtTest/QtTest>
22
23void UpdaterTest::parseVersionsTest_data()
24{
25 QTest::addColumn<QString>("versionString");
26 QTest::addColumn<bool>("valid");
27 QTest::addColumn<int>("major");
28 QTest::addColumn<int>("minor");
29 QTest::addColumn<int>("revision");
30
31 QTest::newRow("zeros") << "0.0.0" << true << 0 << 0 << 0;
32 QTest::newRow("zero-1") << "0.0.1" << true << 0 << 0 << 1;
33 QTest::newRow("current") << "1.4.1" << true << 1 << 4 << 1;
34 QTest::newRow("next-bugfix") << "1.4.2" << true << 1 << 4 << 2;
35 QTest::newRow("2digits") << "2.5.15" << true << 2 << 5 << 15;
36 QTest::newRow("3digits") << "123.123.333" << true << 123 << 123 << 333;
37 QTest::newRow("negative") << "-1.4.1" << false << 0 << 0 << 0;
38 QTest::newRow("invalid") << "0.0.0-1" << false << 0 << 0 << 0;
39 QTest::newRow("invalid2") << "invalid1text" << false << 0 << 0 << 0;
40}
41
42void UpdaterTest::parseVersionsTest()
43{
44 QFETCH(QString, versionString);
45 QFETCH(bool, valid);
46 QFETCH(int, major);
47 QFETCH(int, minor);
48 QFETCH(int, revision);
49
50 Updater::Version v(versionString);
51
52 QCOMPARE(v.isValid, valid);
53
54 if (valid) {
55 QCOMPARE(v.majorVersion, major);
56 QCOMPARE(v.minorVersion, minor);
57 QCOMPARE(v.revisionNumber, revision);
58 }
59}
60
61void UpdaterTest::compareVersionsTest_data()
62{
63 QTest::addColumn<QString>("version1");
64 QTest::addColumn<QString>("version2");
65 QTest::addColumn<bool>("less");
66 QTest::addColumn<bool>("more");
67 QTest::addColumn<bool>("equal");
68
69 QTest::newRow("test1") << "0.0.1" << "0.0.2" << true << false << false;
70 QTest::newRow("test2") << "0.1.2" << "0.0.2" << false << true << false;
71 QTest::newRow("test3") << "1.0.1" << "0.0.2" << false << true << false;
72 QTest::newRow("test4") << "1.4.1" << "1.4.2" << true << false << false;
73 QTest::newRow("test5") << "1.5.0" << "1.4.2" << false << true << false;
74 QTest::newRow("test6") << "1.5.0" << "1.5.0" << false << false << true;
75 QTest::newRow("test7") << "1.5.1" << "1.4.2" << false << true << false;
76 QTest::newRow("test8") << "1.4.1" << "1.4.2" << true << false << false;
77}
78
79void UpdaterTest::compareVersionsTest()
80{
81 QFETCH(QString, version1);
82 QFETCH(QString, version2);
83 QFETCH(bool, less);
84 QFETCH(bool, more);
85 QFETCH(bool, equal);
86
87 Updater::Version v1(version1);
88 Updater::Version v2(version2);
89
90 QCOMPARE(v1 < v2, less);
91 QCOMPARE(v1 > v2, more);
92 QCOMPARE(v1 == v2, equal);
93}
94
95QTEST_GUILESS_MAIN(UpdaterTest)