File: testlap.cpp

package info (click to toggle)
kronometer 2.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,220 kB
  • sloc: cpp: 2,619; xml: 470; makefile: 7; sh: 2
file content (79 lines) | stat: -rw-r--r-- 1,293 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
    SPDX-FileCopyrightText: 2015 Elvis Angelaccio <elvis.angelaccio@kde.org>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "testlap.h"
#include "lap.h"

#include <QTime>

void TestLap::testDefaultLap()
{
    Lap lap;

    QCOMPARE(lap.time(), QTime(0, 0));
    QCOMPARE(lap.raw(), 0);
    QVERIFY(lap.relativeTime().isEmpty());
    QVERIFY(lap.absoluteTime().isEmpty());
}

void TestLap::testLapTime()
{
    QTime time {1, 30};
    Lap lap {time};

    QCOMPARE(lap.time(), time);
}

void TestLap::testRelativeTime()
{
    Lap lap;
    auto test = QLatin1String("test");

    lap.setRelativeTime(test);

    QCOMPARE(lap.relativeTime(), test);
}

void TestLap::testAbsoluteTime()
{
    Lap lap;
    auto test = QLatin1String("test");

    lap.setAbsoluteTime(test);

    QCOMPARE(lap.absoluteTime(), test);
}

void TestLap::testNote()
{
    Lap lap;
    auto test = QLatin1String("test");

    lap.setNote(test);

    QCOMPARE(lap.note(), test);
}

void TestLap::testRawData()
{
    int t = 1000;
    Lap lap = Lap::fromRawData(t);

    QCOMPARE(lap.raw(), t);
}

void TestLap::testTimeTo()
{
    int t1 = 50;
    int t2 = 100;

    Lap lap1 = Lap::fromRawData(t1);
    Lap lap2 = Lap::fromRawData(t2);

    QCOMPARE(lap1.timeTo(lap2).msec(), t2 - t1);
}

QTEST_MAIN(TestLap)