File: kpluralhandlingspinboxtest.cpp

package info (click to toggle)
kf6-ktextwidgets 6.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 23,984 kB
  • sloc: cpp: 5,382; sh: 18; makefile: 7
file content (57 lines) | stat: -rw-r--r-- 1,526 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
/*
    SPDX-FileCopyrightText: 2014 Laurent Montel <montel@kde.org>

    SPDX-License-Identifier: LGPL-2.1-or-later
*/

#include "kpluralhandlingspinboxtest.h"
#include "kpluralhandlingspinbox.h"

#include <QTest>

QTEST_MAIN(KPluralHandlingSpinBoxTest)

KPluralHandlingSpinBoxTest::KPluralHandlingSpinBoxTest()
{
}

void KPluralHandlingSpinBoxTest::shouldHaveDefautValue()
{
    KPluralHandlingSpinBox spinbox;
    QCOMPARE(spinbox.suffix(), QString());
}

void KPluralHandlingSpinBoxTest::shouldUseSingularValueWhenUseValueEqualToOne()
{
    KPluralHandlingSpinBox spinbox;
    spinbox.setSuffix(ki18np("singular", "plural"));
    spinbox.setValue(1);
    QCOMPARE(spinbox.suffix(), QLatin1String("singular"));
}

void KPluralHandlingSpinBoxTest::shouldUsePlurialValueWhenUseValueSuperiorToOne()
{
    KPluralHandlingSpinBox spinbox;
    spinbox.setSuffix(ki18np("singular", "plural"));
    spinbox.setValue(2);
    QCOMPARE(spinbox.suffix(), QLatin1String("plural"));
}

void KPluralHandlingSpinBoxTest::shouldUseSingularValueWhenWeChangeValueAndFinishWithValueEqualOne()
{
    KPluralHandlingSpinBox spinbox;
    spinbox.setSuffix(ki18np("singular", "plural"));
    spinbox.setValue(2);
    spinbox.setValue(1);
    QCOMPARE(spinbox.suffix(), QLatin1String("singular"));
    QCOMPARE(spinbox.value(), 1);
}

void KPluralHandlingSpinBoxTest::shouldReturnEmptySuffix()
{
    KPluralHandlingSpinBox spinbox;
    spinbox.setValue(2);
    QCOMPARE(spinbox.suffix(), QString());
}

#include "moc_kpluralhandlingspinboxtest.cpp"