File indexing completed on 2024-05-12 17:21:31

0001 /*
0002     Copyright (C) 2015 by Elvis Angelaccio <elvis.angelaccio@kde.org>
0003 
0004     This file is part of Kronometer.
0005 
0006     Kronometer is free software: you can redistribute it and/or modify
0007     it under the terms of the GNU General Public License as published by
0008     the Free Software Foundation, either version 2 of the License, or
0009     (at your option) any later version.
0010 
0011     Kronometer is distributed in the hope that it will be useful,
0012     but WITHOUT ANY WARRANTY; without even the implied warranty of
0013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014     GNU General Public License for more details.
0015 
0016     You should have received a copy of the GNU General Public License
0017     along with Kronometer.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 #include "testlap.h"
0021 #include "lap.h"
0022 
0023 #include <QTime>
0024 
0025 void TestLap::testDefaultLap()
0026 {
0027     Lap lap;
0028 
0029     QCOMPARE(lap.time(), QTime(0, 0));
0030     QCOMPARE(lap.raw(), 0);
0031     QVERIFY(lap.relativeTime().isEmpty());
0032     QVERIFY(lap.absoluteTime().isEmpty());
0033 }
0034 
0035 void TestLap::testLapTime()
0036 {
0037     QTime time {1, 30};
0038     Lap lap {time};
0039 
0040     QCOMPARE(lap.time(), time);
0041 }
0042 
0043 void TestLap::testRelativeTime()
0044 {
0045     Lap lap;
0046     auto test = QLatin1String("test");
0047 
0048     lap.setRelativeTime(test);
0049 
0050     QCOMPARE(lap.relativeTime(), test);
0051 }
0052 
0053 void TestLap::testAbsoluteTime()
0054 {
0055     Lap lap;
0056     auto test = QLatin1String("test");
0057 
0058     lap.setAbsoluteTime(test);
0059 
0060     QCOMPARE(lap.absoluteTime(), test);
0061 }
0062 
0063 void TestLap::testNote()
0064 {
0065     Lap lap;
0066     auto test = QLatin1String("test");
0067 
0068     lap.setNote(test);
0069 
0070     QCOMPARE(lap.note(), test);
0071 }
0072 
0073 void TestLap::testRawData()
0074 {
0075     int t = 1000;
0076     Lap lap = Lap::fromRawData(t);
0077 
0078     QCOMPARE(lap.raw(), t);
0079 }
0080 
0081 void TestLap::testTimeTo()
0082 {
0083     int t1 = 50;
0084     int t2 = 100;
0085 
0086     Lap lap1 = Lap::fromRawData(t1);
0087     Lap lap2 = Lap::fromRawData(t2);
0088 
0089     QCOMPARE(lap1.timeTo(lap2).msec(), t2 - t1);
0090 }
0091 
0092 QTEST_MAIN(TestLap)