File indexing completed on 2024-04-14 03:56:06

0001 /*
0002     SPDX-FileCopyrightText: 2014 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #include "kpluralhandlingspinboxtest.h"
0008 #include "kpluralhandlingspinbox.h"
0009 
0010 #include <QTest>
0011 
0012 QTEST_MAIN(KPluralHandlingSpinBoxTest)
0013 
0014 KPluralHandlingSpinBoxTest::KPluralHandlingSpinBoxTest()
0015 {
0016 }
0017 
0018 void KPluralHandlingSpinBoxTest::shouldHaveDefautValue()
0019 {
0020     KPluralHandlingSpinBox spinbox;
0021     QCOMPARE(spinbox.suffix(), QString());
0022 }
0023 
0024 void KPluralHandlingSpinBoxTest::shouldUseSingularValueWhenUseValueEqualToOne()
0025 {
0026     KPluralHandlingSpinBox spinbox;
0027     spinbox.setSuffix(ki18np("singular", "plural"));
0028     spinbox.setValue(1);
0029     QCOMPARE(spinbox.suffix(), QLatin1String("singular"));
0030 }
0031 
0032 void KPluralHandlingSpinBoxTest::shouldUsePlurialValueWhenUseValueSuperiorToOne()
0033 {
0034     KPluralHandlingSpinBox spinbox;
0035     spinbox.setSuffix(ki18np("singular", "plural"));
0036     spinbox.setValue(2);
0037     QCOMPARE(spinbox.suffix(), QLatin1String("plural"));
0038 }
0039 
0040 void KPluralHandlingSpinBoxTest::shouldUseSingularValueWhenWeChangeValueAndFinishWithValueEqualOne()
0041 {
0042     KPluralHandlingSpinBox spinbox;
0043     spinbox.setSuffix(ki18np("singular", "plural"));
0044     spinbox.setValue(2);
0045     spinbox.setValue(1);
0046     QCOMPARE(spinbox.suffix(), QLatin1String("singular"));
0047     QCOMPARE(spinbox.value(), 1);
0048 }
0049 
0050 void KPluralHandlingSpinBoxTest::shouldReturnEmptySuffix()
0051 {
0052     KPluralHandlingSpinBox spinbox;
0053     spinbox.setValue(2);
0054     QCOMPARE(spinbox.suffix(), QString());
0055 }
0056 
0057 #include "moc_kpluralhandlingspinboxtest.cpp"